Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

I have a question about GROUPING SETS and the () element. Expand / Collapse
Author
Message
Posted Sunday, January 20, 2013 12:03 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, December 28, 2013 5:45 PM
Points: 94, Visits: 96
What does the () signify with grouping sets of multiple elements?

An example on Microsoft.com, (http://technet.microsoft.com/en-us/library/bb522495(v=sql.105).aspx), read the following T-SQL code:

GROUP BY GROUPING SETS(
(T.[Group], T.CountryRegionCode)
,(S.Name)
,(H.SalesPersonID,T.[Group])
,(H.SalesPersonID)
,())


What does the last open parenthesis and its closing parenthesis "()" mean?

I think has the effect of a UNION of GROUP BY () nothing. But I don't know why you would want the results of a GROUP BY () that doesn't have any value.
Post #1409297
Posted Sunday, January 20, 2013 12:29 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, July 17, 2014 6:47 AM
Points: 223, Visits: 1,718
Empty set add a grand total.
http://www.sqlsnippets.com/en/topic-13122.html
Post #1409298
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse