1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘tb1.create_date’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
语句如下:
select DATE_ADD(DATE_FORMAT(create_date,‘%Y-%m-%d’),INTERVAL 2 Day) ,count(1) from tb1 where create_date>‘2020-09-01’ GROUP BY DATE_FORMAT(create_date,‘%Y-%m-%d’)
以上语句会报 group by错误
但是 select DATE_ADD(create_date,INTERVAL 2 Day) ,count(1) from tb1 where create_date>‘2020-09-01’ GROUP BY create_date
又是可正常得到结果
select DATE_FORMAT(create_date,‘%Y-%m-%d’) ,count(1) from tb1 where create_date>‘2020-09-01’ GROUP BY DATE_FORMAT(create_date,‘%Y-%m-%d’)
可以修改为: select DATE_ADD(DATE_FORMAT(create_date,‘%Y-%m-%d’),INTERVAL 2 Day) ,count(1) from tb1 where create_date>‘2020-09-01’ GROUP BY DATE_ADD(DATE_FORMAT(create_date,‘%Y-%m-%d’),INTERVAL 2 Day); 试试