我有按月报告的MySQL查询,但是当我尝试在我的Linux盒子Debian上执行它时,它不再起作用了。它适用于我的Windows框,我的查询看起来像这样。我必须按月订购我的销售,但不是。
我该如何解决?
SELECT COUNT(*) AS orders, ROUND(SUM(total),2) AS total, MONTHNAME(created_at) AS MONTH
FROM storelte_order
WHERE STATUS = 1
AND YEAR(created_at) = YEAR(CURDATE())
GROUP BY MONTH
ORDER BY created_at ASC;
错误:
22:14:34 call sales_by_month Error Code: 1055. Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'storelte.storelte_order.created_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 0.041 sec
------------------------------------------------------------------------
答案 0 :(得分:0)
据我所知,你可以用两种方式解决它