MySQL查询无法在Linux上运行

时间:2017-10-04 04:21:31

标签: mysql linux

我有按月报告的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
------------------------------------------------------------------------

1 个答案:

答案 0 :(得分:0)

据我所知,你可以用两种方式解决它

  1. 按照here
  2. 所述重新配置您的linux mysql
  3. 重写您的查询(假设将created_at替换为3(表示结果中的MONTH列)。