数据

  1. --复杂统计函数
  2. CREATE TABLE t3 (color_type varchar(20), in_date varchar(30),color_count int);
  3. INSERT INTO t3 (color_type,in_date,color_count) VALUES('black','2010-09-11',18);
  4. INSERT INTO t3 (color_type,in_date,color_count) VALUES('black','2010-10-05',18);
  5. INSERT INTO t3 (color_type,in_date,color_count) VALUES('black','2010-10-13',31);
  6. INSERT INTO t3 (color_type,in_date,color_count) VALUES('blue','2010-09-21',23);
  7. INSERT INTO t3 (color_type,in_date,color_count) VALUES('blue','2010-09-30',15);
  8. INSERT INTO t3 (color_type,in_date,color_count) VALUES('blue','2010-10-11',62);
  9. INSERT INTO t3 (color_type,in_date,color_count) VALUES('red','2010-09-12',41);
  10. INSERT INTO t3 (color_type,in_date,color_count) VALUES('red','2010-10-01',12);
  11. 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函数的更多相关文章

  1. PostgreSQL中的pg_relation_filepath()函数

    pg_relation_filepath()类似于pg_relation_filenode(),但它返回关系的整个文件路径名(相对于数据库集群的数据目录PGDATA). postgres=# sele ...

  2. PostgreSQL的时间/日期函数使用

    PostgreSQL的常用时间函数使用整理如下: 一.获取系统时间函数 1.1 获取当前完整时间 select now(); david=# select now(); now ----------- ...

  3. 【转】Kylin中的cube构建

    http://blog.csdn.net/yu616568/article/details/50365240 前言   在使用Kylin的时候,最重要的一步就是创建cube的模型定义,即指定度量和维度 ...

  4. PostgreSQL 中日期类型转换与变量使用及相关问题

    PostgreSQL中日期类型与字符串类型的转换方法 示例如下: postgres=# select current_date; date ------------ 2015-08-31 (1 row ...

  5. PostgreSQL+PostGIS的使用 函数清单

    一. PostgreSQL与PostGIS的关系 PostgreSQL 是世界上技术最先进的开源数据库,其前身是1977年一个源于Berkeley名为Ingres的非关系型数据库,其项目领导人为Mic ...

  6. [转] PostgreSQL的时间/日期函数使用

    PS:http://blog.csdn.net/love_rongrong/article/details/6712883 字符串模糊比较 日期类型的模糊查询是不能直接进行的,要先转换成字符串然后再查 ...

  7. Mysql中的常用函数:

    Mysql中的常用函数: 1.字符串函数: (1).合并字符串 concat():// concat('M','y',"SQL",'5.5');== MySQL5.5//当传入的参 ...

  8. PostgreSQL 中如何实现group_concat

    之前在MySQL中使用group_concat,觉得超级好用. 今天在PostgreSQL需要用到这样的场景,就去学习了一下. 在PostgreSQL中提供了arr_agg的函数来实现聚合,不过返回的 ...

  9. trueStudio中使用printf函数

    1.通过printf输出浮点数需要如下设置: 在工程属性下找到C/C++ build->Settings->Tool Settings->C Linker->Miscellan ...

随机推荐

  1. 快速排序算法 quick sort的理解

    最近做了一下算法的一些练习,感觉基础薄弱了,只是用一些已经有的东西来完成练习如quickSort(c++使用的时候是sort(起始位置,终止位置,比较函数),这个需要加头文件),但是不知道怎么推出来, ...

  2. php调接口

    浏览器直接访问接口时会弹出账号密码框 当用程序调用时需要加入    curl_setopt($ch, CURLOPT_USERPWD, "$username:$password") ...

  3. Linux下Source Insight的安装和汉化

    原创文章,转载请注明出处. 工欲善其事,必先利其器.Source Insight绝对是阅读C和C++代码的利器,另外,Source Insight的体量很小,安装便捷,显示直观,比vim+cscope ...

  4. [LeetCode] 132 Pattern 132模式

    Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that  ...

  5. [LeetCode] Permutation Sequence 序列排序

    The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of the p ...

  6. JavaScript模板引擎artTemplate.js——引入子模板

    之前的例子都是单一结构的对象,如果遇到复杂对象结构,我们可以通过引入子模板来实现html的渲染. 依旧以之前的数据作为例子: <div id="content">< ...

  7. C++知识回顾(一)

    感觉世界都是约定好的,每门语言的第一个程序总是Hello World!但是也有一些书似乎是在追求个性,会用一些其他的,但是是Not Hello World!本人需要再学习一下C++,所以从最基础的开始 ...

  8. jquery获取url参数及url加参数的方法

    转--http://www.jb51.net/article/73896.htm <script src="js/jquery-1.7.2.min.js" type=&quo ...

  9. Android基础总结(四)

    网络图片查看器 确定图片的网址 发送http请求 URL url = new URL(address); //获取连接对象,并没有建立连接 HttpURLConnection conn = (Http ...

  10. mybatis generator.xml 配置 自动生成model,dao,mapping

    generator.xml文件: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE gener ...