SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Grouping sets with identifier
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Luuk123
Yak Posting Veteran

52 Posts

Posted - 10/31/2013 :  03:48:08  Show Profile  Reply with Quote
Hi all,

I have a query that generates invoices which checks an input parameter (period) to determine if the grouping is per week/4weeks/month.

I can use three seperate querys, each for one grouping-type, but I'm wondering if there's a way to use one query with a grouping set dependend on the parameter.

Using grouping sets is such a way, but this generates results for all three grouping sets and I can't identify which one is needed.

Does anyone have an idea?

Thanks!

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/31/2013 :  04:04:26  Show Profile  Reply with Quote
you can use GROUPING_ID to identify different groups

http://technet.microsoft.com/en-us/library/bb510624.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

Luuk123
Yak Posting Veteran

52 Posts

Posted - 10/31/2013 :  08:07:48  Show Profile  Reply with Quote
Thanks, it works!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/31/2013 :  08:28:02  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000