• Either I read the BOL totally wrong, or you got the answer totally wrong.

    The BOL (linked in your answer) says they are equivalent. Unless "equivalent" does not equal to "the same"?

    Specifying GROUPING SETS ( [,...n ]) as the GROUP BY list is equivalent to a UNION ALL of queries, each with one of the grouping sets as its GROUP BY list. Aggregates on floating-point numbers might return slightly different results.

    The following statements are equivalent:

    SELECT customer, year, SUM(sales)

    FROM T

    GROUP BY GROUPING SETS ((customer), (year))

    SELECT customer, NULL as year, SUM(sales)

    FROM T

    GROUP BY customer

    UNION ALL

    SELECT NULL as customer, year, SUM(sales)

    FROM T

    GROUP BY year


    Urbis, an urban transformation company