title: Understanding the differences between CUBE and ROLLUP
body: <p>My assignment asked me to find out "how many invoices are written for each date?"</p>
  
  <p>I was a little stuck and asked my professor for help. She emailed me a query that would answer the question, "How many stoves of each type and version have been built?
  For a challenge but no extra points, include the total number of stoves."</p>
  
  <p>This was the query she sent me:</p>
  
  <pre><code>SELECT STOVE.Type + STOVE.Version AS 'Type+Version'
  , COUNT(*) AS 'The Count'
  FROM STOVE
  GROUP BY STOVE.Type + STOVE.Version WITH ROLLUP;
  </code></pre>
  
  <p>So, I tweaked that query until it met my needs. This is what I came up with:</p>
  
  <pre><code>SELECT InvoiceDt
  , COUNT(InvoiceNbr) AS 'Number of Invoices' 
  FROM INVOICE 
  GROUP BY InvoiceDt WITH ROLLUP 
  ORDER BY InvoiceDt ASC;
  </code></pre>
  
  <p>And it returned the following results that I wanted. </p>
  
  <p>Anyway, I decided to read up on the ROLLUP clause and started with an article from <a href="http://msdn.microsoft.com/en-us/library/ms189305%28v=sql.90%29.aspx">Microsoft</a>. It said that the ROLLUP clause was similar to the CUBE clause but that it was distinguished from the CUBE clause in the following way:</p>
  
  <ol>
  <li>CUBE generates a result set that shows aggregates for all combinations of values in the selected columns.</li>
  <li>ROLLUP generates a result set that shows aggregates for a hierarchy of values in the selected columns.</li>
  </ol>
  
  <p>So, I decided to replace the ROLLUP in my query with CUBE to see what would happen. They produced the same results. I guess that's where I'm getting confused.</p>
  
  <p>It seems like, if you're using the type of query that I am here, that there isn't any practical difference between the two clauses. Is that right? Or, am I not understanding something? I had thought, when I finished reading the Microsoft article, that my results should've been different using the CUBE clause.</p>