postgresql中的CUBE函数
数据
--复杂统计函数CREATE TABLE t3 (color_type varchar(20), in_date varchar(30),color_count int);INSERT INTO t3 (color_type,in_date,color_count) VALUES('black','2010-09-11',18);INSERT INTO t3 (color_type,in_date,color_count) VALUES('black','2010-10-05',18);INSERT INTO t3 (color_type,in_date,color_count) VALUES('black','2010-10-13',31);INSERT INTO t3 (color_type,in_date,color_count) VALUES('blue','2010-09-21',23);INSERT INTO t3 (color_type,in_date,color_count) VALUES('blue','2010-09-30',15);INSERT INTO t3 (color_type,in_date,color_count) VALUES('blue','2010-10-11',62);INSERT INTO t3 (color_type,in_date,color_count) VALUES('red','2010-09-12',41);INSERT INTO t3 (color_type,in_date,color_count) VALUES('red','2010-10-01',12);INSERT INTO t3 (color_type,in_date,color_count) VALUES('red','2010-10-05',11);
函数简介
CUBE(a, b, c):和grouping sets((a,b,c),(a,b),(a,c),(a),(b,c),(b),(c),())是等效的
如下所示:

其中:
- black共计67,
- blue共计100
- red共计64
- 所有共计231
添加汇总额外信息
如下所示,添加了总计、小计等信息:
postgresql中的CUBE函数的更多相关文章
- PostgreSQL中的pg_relation_filepath()函数
pg_relation_filepath()类似于pg_relation_filenode(),但它返回关系的整个文件路径名(相对于数据库集群的数据目录PGDATA). postgres=# sele ...
- PostgreSQL的时间/日期函数使用
PostgreSQL的常用时间函数使用整理如下: 一.获取系统时间函数 1.1 获取当前完整时间 select now(); david=# select now(); now ----------- ...
- 【转】Kylin中的cube构建
http://blog.csdn.net/yu616568/article/details/50365240 前言 在使用Kylin的时候,最重要的一步就是创建cube的模型定义,即指定度量和维度 ...
- PostgreSQL 中日期类型转换与变量使用及相关问题
PostgreSQL中日期类型与字符串类型的转换方法 示例如下: postgres=# select current_date; date ------------ 2015-08-31 (1 row ...
- PostgreSQL+PostGIS的使用 函数清单
一. PostgreSQL与PostGIS的关系 PostgreSQL 是世界上技术最先进的开源数据库,其前身是1977年一个源于Berkeley名为Ingres的非关系型数据库,其项目领导人为Mic ...
- [转] PostgreSQL的时间/日期函数使用
PS:http://blog.csdn.net/love_rongrong/article/details/6712883 字符串模糊比较 日期类型的模糊查询是不能直接进行的,要先转换成字符串然后再查 ...
- Mysql中的常用函数:
Mysql中的常用函数: 1.字符串函数: (1).合并字符串 concat():// concat('M','y',"SQL",'5.5');== MySQL5.5//当传入的参 ...
- PostgreSQL 中如何实现group_concat
之前在MySQL中使用group_concat,觉得超级好用. 今天在PostgreSQL需要用到这样的场景,就去学习了一下. 在PostgreSQL中提供了arr_agg的函数来实现聚合,不过返回的 ...
- trueStudio中使用printf函数
1.通过printf输出浮点数需要如下设置: 在工程属性下找到C/C++ build->Settings->Tool Settings->C Linker->Miscellan ...
随机推荐
- BZOJ 1087: [SCOI2005]互不侵犯King [状压DP]
1087: [SCOI2005]互不侵犯King Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3336 Solved: 1936[Submit][ ...
- MFC快速入门 - 菜单
本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6231104.html 打开VS2010,依次打开File – New – Proje ...
- python中的迭代器
1.可以直接作用于for循环的数据类型 第一类:集合数据类型,如list.tuple.dict.set.str等: 第二类:generator,包括集合定义generator和带yield的gener ...
- 新手学跨域之iframe
https://segmentfault.com/a/1190000000702539 页面嵌套iframe是比较常见的,比如QQ相关业务页面的登录框一般都是iframe的.使用ifrmae跨域要满足 ...
- [Membership架构分析1] ASP.NET membership的表结构
转自:http://blog.sina.com.cn/s/blog_650b9ecc0100iqfo.html 1)表名:aspnet_Applications 说明:保存应用程序信息(系统名) 每一 ...
- MySQL/MariaDB/PerconaDB-提权条件竞争漏洞
背景 2016年11月01日,国外安全研究员Dawid Golunski在 MySQl, MariaDB 和 PerconaDB 数据库中发现条件竞争漏洞,该漏洞允许本地用户使用低权限(CREATE/ ...
- javascript json字符串与对象相互转换
在实际项目中,经常遇到字符格式的问题,记下来以便日后方便查看.用到两个函数:JSON.stringify() 和 JSON.parse(). 使用ajax向后台请求数据,后台给前端返回数据,明明后端脚 ...
- grails项目获取前后台的值
grails项目中前台传值给后台: 加入我有a.gsp这个页面,a.gsp中有如下代码: 姓名:<input type="text" name="xing" ...
- 微信Api分享
这些都是以前积累的东西,有很多都是参考了别人的,都忘记出处了,请大家谅解.参考微信开发者平台 https://open.weixin.qq.com/cgi-bin/showdocument?actio ...
- Ubuntu安装RobotFramework
安装Python Ubuntu默认已安装 安装pip wget https://bootstrap.pypa.io/get-pip.py python get-pip.py 安装RobotFramew ...
