数据

  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. OnDraw函数

    本文仅用于学习交流,商业用途请支持正版!转载请注明:http://www.cnblogs.com/mxbs/p/6219428.html 方法一.对字符串直接赋值 在View类中定义了OnDraw函数 ...

  2. [python]设计模式

    需要说明:java跟python在思维模式上并不一样,java利用接口以及多态可以实现很多抽象上的东西,而python不行,其实以下很多设计模式写法并不适用也没有必要,更多是为了对比和帮助理解这些设计 ...

  3. virtualBox安装Centos7之后

    之前用vmware装虚拟机的时候,直接配置好网卡就可以ping通,可以用ssh登录,然后配置yum源,万事大吉. 但是virtualBox配置却有不同,需要按下面的方法配置: 选中虚拟机->设置 ...

  4. ubuntu 14.04 desktop装vnc4server

    ubuntu 14.04 desktop上安装vnc4server要装上gnome的一些软件包并修改启动文件~/.vnc/xstartup 问题来源How to make VNC Server wor ...

  5. [LeetCode] Reverse Linked List II 倒置链表之二

    Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1-> ...

  6. valueOf和toString的区别

    基本上所有的JavaScript数据类型都有valueOf(),toString()方法,null除外,这两个方法解决了JavaScript值运算和显示的问题 valueOf()会把数据类型转换成原始 ...

  7. hql中in关键字的用法

    hql: from " + FoodComment.class.getName() + " f where f.id in :groupIds" 封装的方法: publi ...

  8. SSM整合(三):Spring4与Mybatis3与SpringMVC整合

    源码下载 SSMDemo 上一节整合了Mybatis3与Spring4,接下来整合SpringMVC! 说明:整合SpringMVC必须是在web项目中,所以前期,新建的就是web项目! 本节全部采用 ...

  9. 篇二:JSON解析

    前台以json形式的数据格式传到后台,代码如下: import net.sf.json.JSONObject; public class JsonUtility { /** * 解析JSON 对象为对 ...

  10. Tween公式 以及四个参数

    Tween的主页在这里:http://createjs.com/tweenjs , 这里边还有挺多开源项目的: Tween公式 4个参数 t:current time(当前时间) b:beginnin ...