sql学习-GROUP BY

GROUP BY 子句

介绍

在SELECT 列表中 所有未包含在 ** 组函数 ** 中的列 都应该包含在GROUP BY 子句中。

语法

SELECT deptno,AVG(sal) from emp GROUP BY deptno;
-- deptno 是没有包含在组函数中的列 --

错误语法

SELECT a,b,c,AVG(sal) from emp GROUP BY a,b;
-- c没有写在group by 后面 -- 

推荐

推荐看这篇博客 (Oracle 中关于 Group By 子句与多行函数嵌套搭配使用的注意事项)[https://www.cnblogs.com/askscuti/p/12134220.html], 这篇文章讲的很仔细。

猜你喜欢

转载自blog.csdn.net/flower_48237/article/details/107796242
今日推荐