项目场景:Oracle 数据库:不是GROUP BY 表达式
问题描述:
错误提示:ORA-000979:不是GROUP BY 表达式
例如:
select col1,col2,sun(clo3),col4
from table1
where col4 = "aaa"
group by col2
order by col2
原因分析:
在使用group by 时,有一个规则需要遵守,即出现在select列表中的字段,如果没有在组函数中,那么必须出现在group by 子句中。(select中的字段不可以单独出现,必须出现在group语句中或者在组函数中。)
解决方案:
```sql select col1,col2,sun(clo3),col4 from table1 where col4 = "aaa" group by col1,col2,col4 order by col2 ```详细解释:group by