Hacker News new | ask | show | jobs
by spamizbad 3823 days ago
I'm very excited about CUBE and ROLLUP -- I am just about to start a project that barely requires an OLAP shim. Now it looks like I can just do it all with just database features. Yay for fewer dependencies!
1 comments

I'm not familiar with those statements, can you provide an example?
They're useful for providing summaries like row totals and column totals. Rather than just get an aggregated count for the total GROUP, you can also get aggregated counts for each unique combination of columns within the GROUP.

  col1 col2 count  
  ---- ---- -----  
  a    b    10  
  a    null 5  
  null b    5  
There's more to it than that obviously, but you can read about them here: http://www.postgresql.org/docs/devel/static/queries-table-ex... (7.2.4. GROUPING SETS, CUBE, and ROLLUP)