gpt4 book ai didi

MySQL 查询在 Linux 上不工作

转载 作者:太空宇宙 更新时间:2023-11-04 12:19:03 25 4
gpt4 key购买 nike

我有一个按月报告的 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. 按照描述重新配置您的 linux mysql here
  2. 重写您的查询(假设将 created_at 替换为 3(表示结果中的 MONTH 列)。

关于MySQL 查询在 Linux 上不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46556969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com