0

I have a MySQL query for sales by month report, but when I try to execute it on my Linux box Debian it didn't work anymore. It works on my Windows box, and my query looks like this. I have to order my sales by month, but however doesn't it.

How can I fix it?

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;

Error:

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 Answers1

0

As I understand you can fix it in two ways

  1. Reconfigure your linux mysql as described here
  2. Rewrite your query (let say replace created_at by 3 (means MONTH column in result).
Vasyl Moskalov
  • 4,242
  • 3
  • 20
  • 28