MySql 错误:In aggregated query without GROUP BY, expression #1 of SELECT list contains....

select c_no,AVG(sc_degree) from score where s_no IN (select s_no from student where s_class = '95031');

运行上述查询时,弹出一下错误

select c_no,AVG(sc_degree) from score where s_no IN (select s_no from student where s_class = '95031')
> 1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'school_test.score.c_no'; this is incompatible with sql_mode=only_full_group_by
> 时间: 0.001s

经过查询资料和测试,当mysql的sql_mode是only_full_group_by的时候,在不使用group by 并且select后面出现聚集函数的话,那么所有被select的都应该是聚集函数,否则就会报错

猜你喜欢

转载自www.cnblogs.com/cbma0116/p/12084746.html