Stairway to T-SQL DML Level 8: Using the ROLLUP, CUBE and GROUPING SET operator in a GROUP BY Clause

  • Comments posted to this topic are about the item Stairway to T-SQL DML Level 8: Using the ROLLUP, CUBE and GROUPING SET operator in a GROUP BY Clause

    Gregory A. Larsen, MVP

  • Greg Larsen (1/10/2012)


    Comments posted to this topic are about the item <A HREF="/articles/Stairway+Series/87629/">Stairway to T-SQL DML Level 8: Using the ROLLUP, CUBE and GROUPING SET operator in a GROUP BY Clause</A>

    It is an amazing article on the Rollup, Cube and Grouping SEt operators. Excelling explanation and very good presentation with very simple example.

  • Good article, but I've been surprised with the use of COALESCE() for getting the 'Grand Total' in Listing 3. I think it's better to use the GROUPING() function to know if we are dealing with a subtotal row, and then replace the NULL with the correct label. If you use COALESCE() and there is some NULL value in the column CheckFor, you'll get a mistaken label.

  • Thanks for this, it's a good clear summary of these features.

    Are there any performance gains to be had by switching to use these features over unioning a set of SQL statements together? If so I have a few reports that might benefit from rewriting to use them.

    Barney

  • Nice article! I had never really thought much about using those powerful options with GROUP BY, but now I will use them more.

    --Bill

  • test

  • Good article and clear explanation.

    Had do refactor the INSERT statements as my organisation uses SQL 2005.

    :exclamation: "Be brave. Take risks. Nothing can substitute experience." :exclamation:

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply