博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第28章 高级分组函数
阅读量:7244 次
发布时间:2019-06-29

本文共 499 字,大约阅读时间需要 1 分钟。

第28章 高级分组函数

select deptno,sum(sal) from emp group by deptno
union all

select null,sum(sal) from emp;

 

 

 

 

 

 

 

 

分组的规则

grouping 查看列是否参与分组

为0的就是参与分组了,为1就是没有参与分组

select deptno,job,sum(sal),grouping(deptno),grouping(job) from emp group by cube(deptno,job);

 

rouping sets()合并分组

select deptno,null job,sum(sal) from emp group by deptno
union all
select null,job,sum(sal) from emp group by job;

select deptno,job,sum(sal) from emp group by grouping sets(deptno,job);

 

 

转载于:https://www.cnblogs.com/tudousix/p/9417753.html

你可能感兴趣的文章
脚本初步
查看>>
svn 常见问题记录
查看>>
IIS 部署 python web框架 Flask
查看>>
MariaDB基础(2)—管理篇
查看>>
教你如何用 lib-flexible 实现移动端H5页面适配
查看>>
mysql5.6中的reset slave和reset master 参数的介绍和应用
查看>>
MySQL 命令行工具mycli
查看>>
如何使用LVM卷管理Linux系统中的磁盘
查看>>
我的友情链接
查看>>
linux下ntp服务配置
查看>>
StringBuffer 和 StringBiulder的区别
查看>>
Android新浪微博下拉刷新(最新消息显示在最上面)
查看>>
我的友情链接
查看>>
EDM营销如何激发客户的购买欲
查看>>
广域网中ppp协议的验证
查看>>
Cisco ASA 5585 with firepower configuration for cluster 基本配置
查看>>
linux用户权限管理
查看>>
短消息调试笔记
查看>>
suse11安装测试redis
查看>>
如何使用Audition消除音乐中的人声
查看>>