Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Multiple grouping sets - placeholder?

Author  Topic 

chihwahli
Starting Member

11 Posts

Posted - 2013-02-22 : 15:45:28

Hello all,

Thanks for helping out!

The following query will use placeholders (NULL) if an element is not part of the grouping set.

From what I understand is that columns can be NULL or have an value.
I only 'see' two possible values:

1) a shipping city is filled in, for instance with the value 'xxx'
2) nothing is filled in, thus it's NULL, unknown.
3) what is the third??

What does it mean "an element is not part of the grouping set" ?


SELECT shipcountry, shipregion, shipcity, COUNT(*) AS numorders
FROM Sales.Orders
GROUP BY ROLLUP( shipcountry, shipregion, shipcity );

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-23 : 02:13:01
The third is total rows for one of category ie for ex. total for particular country or region or city. It will have NULL for the other columns

see

http://databases.about.com/od/sql/l/aacuberollup.htm

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -