Sunday, July 28, 2013

Learn You Some SQL For Great Good - Unlearn What You Have Learned OR How Select Logically Works (the WITH CUBE or WITH ROLLUP clause)

"They came upon me as a wide breaking in of waters:
in the desolation they rolled themselves upon me.
"
-- Job 30:14

We are now onto WITH CUBE and WITH ROLLUP in our trip down the SELECT clause.

  1. FROM
  2. ON
  3. JOIN
  4. WHERE
  5. GROUP BY
  6. WITH CUBE or WITH ROLLUP
  7. HAVING
  8. SELECT
  9. DISTINCT
  10. ORDER BY
  11. TOP
I would be lying if I say I have ever used these.  Instead of bsing my way through them, I will instead give links to others that seem to know what they are talking about.  At sometime if I actually use them I may come back and put actual content.

Pinal Dave is one of the first people I look to when I need to know something about SQL Server here is a link to his  blog on WITH ROLLUP: http://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause/

Craig Freedman has a blog entry on WITH ROLLUP: http://blogs.msdn.com/b/craigfr/archive/2007/09/21/aggregation-with-rollup.aspx and another on WITH CUBE: http://blogs.msdn.com/b/craigfr/archive/2007/09/27/aggregation-with-cube.aspx