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 ...
随机推荐
- XIB——AutoLayout添加约束
仿QQ登录界面: 说明:以下各图背景红色只是方便看清楚: 1.创建工程:创建xib文件,不会,可看上上上篇:初识xib: 2.打开xib文件: (1).创建头像: 拖控件:uiimageview--& ...
- BZOJ1298[SCOI2009]骰子的学问
Description Input 第一行为两个整数n, m.第二行有n个整数,为a1,a2, -, an. Output 包含n行,每行m个1~n×m的正整数,各不相同,以空格分开.如果有多解,输出 ...
- [LeetCode] Zigzag Iterator 之字形迭代器
Given two 1d vectors, implement an iterator to return their elements alternately. For example, given ...
- [LeetCode] Combination Sum 组合之和
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...
- 系统级性能分析工具perf的介绍与使用
测试环境:Ubuntu16.04(在VMWare虚拟机使用perf top存在无法显示问题) Kernel:3.13.0-32 系统级性能优化通常包括两个阶段:性能剖析(performance pro ...
- 信息中心网络 ,Information-centric networking, ICN
- mysql在空闲8小时之后会断开连接(默认情况)
调试程序的过程发现,在mysql连接空闲一定时间(默认8小时)之后会断开连接,需要重新连接,也引发我对重连机制的思考.
- LAMP(1) 在VirtualBox里安装Ubuntu Server
问题0.虚拟机中安装lamp环境 问题解决: 来自百度经验 问题1. 用putty远程登陆linux系统,显示network error connection refused 问题解决 问题2. my ...
- Leetcode 365. Water and Jug Problem
可以想象有一个无限大的水罐,如果我们有两个杯子x和y,那么原来的问题等价于是否可以通过往里面注入或倒出水从而剩下z. z =? m*x + n*y 如果等式成立,那么z%gcd(x,y) == 0. ...
- 【bzoj3143】 Hnoi2013—游走
http://www.lydsy.com/JudgeOnline/problem.php?id=3143 (题目链接) 题意 一个无向连通图,顶点从1编号到N,边从1编号到M.每一步以相等的概率随机选 ...
