浅浅星空 2022-11-19 18:47 采纳率: 66.7%
浏览 6

mysql查询报错only_full_group_by

为什么一直报错说没分组呢?看了半天也没看出来问题
SQL_ERROR_INFO: "Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'practice_record.submit_time' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by"

select 
date_format(submit_time,'%Y%m') as submit_month,
count(*) as month_q_cnt,
round(count(*)/day(last_day(submit_time)),3) as avg_day_q_cnt 
from practice_record 
group by date_format(submit_time,'%Y%m') 
union all
select  
'2021汇总' as submit_month,
count(*) as month_q_cnt,
round(count(*)/31,3) as avg_day_q_cnt 
from practice_record
order by submit_month;

  • 写回答

3条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-11-19 20:17
    关注
    评论

报告相同问题?

问题事件

  • 创建了问题 11月19日