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的都应该是聚集函数,否则就会报错


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM