I have a grid app. I want only the chart from a summary (the only documented way to get a chart).
Input SQL:
[INDENT]SELECT
ROUND(AVG(Order_Total), 2) AS Avg_Order,
Customer_ID
FROM
t_orders
WHERE Order_Date > (NOW() - INTERVAL 6 MONTH)
GROUP BY Customer_ID
ORDER BY Avg_Order DESC
LIMIT 20
[/INDENT]
When I execute the app, the SQL has been changed to:
[INDENT]select
count(*),
avg(ROUND(AVG(Oder_Total),2)) as avg_order
from t_orders
where Order_Date > (NOW() - INTERVAL 6 MONTH)
group by Customer_ID
[/INDENT]
The field “Customer_ID” (and LIMIT 20, and a random avg() thrown in) have been dropped, making the SELECT fail due to an invalid GROUP BY.