GroupBy styntax violation error
alkadoHs opened this issue · 2 comments
I have these codes that read Orders per day for the week:
But, I'm getting this error
**SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mauzodata.orders.created_at' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
select
date_format(created_at, '%Y-%m-%d') as date,
sum(paid) as aggregate
from
orders
where
created_at
between 2024 -03 -18 00: 00: 00
and 2024 -03 -24 23: 59: 59
group by
date
order by
date
asc**
Disable only_full_group_by mode in your MySQL server
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
Thank for your response.
I got the answer, it was because of the conflict on my orders table, it contains date column and created_at column.
But after deleting date column now it works fine.