聚合函数关于group by后面字段要不要在select后面出现

如题所述

group by后面的字段都要在select后面出现,以下例子仅供参考:

正确的写法:

select col1,col2,sum(col3),avg(col4) from table_name group by col1,col2;

 如果你这样写肯定报错:

select col1,col2,sum(col3),avg(col4) from table_name group by col1;

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答