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),())是等效的

如下所示:
postgresql中的CUBE函数postgresql中的CUBE函数
其中:

  • black共计67,
  • blue共计100
  • red共计64
  • 所有共计231

添加汇总额外信息

如下所示,添加了总计、小计等信息:
postgresql中的CUBE函数

postgresql中的CUBE函数

 

相关文章:

  • 2021-06-26
  • 2022-12-23
  • 2021-09-08
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-06
  • 2021-10-28
  • 2022-12-23
  • 2021-08-18
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案