﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Grouping sets / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 17:55:30 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>can u write a query plz plz</description><pubDate>Sun, 03 Mar 2013 20:01:27 GMT</pubDate><dc:creator>cooljagadeesh</dc:creator></item><item><title>RE: Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>Maybe consider vertical partitioning and recreate in a view?</description><pubDate>Mon, 25 Feb 2013 10:08:49 GMT</pubDate><dc:creator>Erin Ramsay</dc:creator></item><item><title>RE: Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>This is probably the error message you are receiving, correct?[code="plain"]Msg 10706, Level 16, State 1, Line 27Too many expressions are specified in the GROUP BY clause. The maximum number is 32 when grouping sets are supplied.[/code]For a GROUP BY clause that uses ROLLUP, CUBE, or GROUPING SETS, the maximum number of expressions is 32. You will have to remove one of the grouping sets to get the query to finish successfully. Here is a link on GROUPING. [url]http://msdn.microsoft.com/en-us/library/ms177673.aspx[/url]If you drop column 33, the query would run. [code="sql"]declare @tbl table (Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int,Col7 int,Col8 int,Col9 int,Col10 int,Col11 int,Col12 int,Col13 int,Col14 int,Col15 int,Col16 int,Col17 int,Col18 int,Col19 int,Col20 int,Col21 int,Col22 int,Col23 int,Col24 int,Col25 int,Col26 int,Col27 int,Col28 int,Col29 int,Col30 int,Col31 int,Col32 int,Col33 int,col34 int)insert @tblselect 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 10,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 20,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 30,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 40,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34--SELECT * FROM @tbl AS tselect SUM(Col1) Total,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15,Col16,Col17,Col18,Col19,Col20,Col21,Col22,Col23,Col24,Col25,Col26,Col27,Col28,Col29,Col30 from @tblgroup by grouping sets ( (),(Col1,Col2),(Col1,Col2,Col3),(Col1,Col2,Col3,Col4),(Col1,Col2,Col3,Col4,COL5),(Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15,Col16,Col17,Col18,Col19,Col20,Col21,Col22,Col23,Col24,Col25,Col26,Col27,Col28,Col29,Col30,col31,col32))[/code]</description><pubDate>Sun, 24 Feb 2013 17:48:31 GMT</pubDate><dc:creator>SQL_Enthusiast</dc:creator></item><item><title>RE: Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>plz help out dis</description><pubDate>Fri, 22 Feb 2013 20:09:03 GMT</pubDate><dc:creator>cooljagadeesh</dc:creator></item><item><title>RE: Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>please take below exampledeclare @tbl table (Col1 int,Col2 int,Col3 int,Col4 int,Col5 int,Col6 int,Col7 int,Col8 int,Col9 int,Col10 int,Col11 int,Col12 int,Col13 int,Col14 int,Col15 int,Col16 int,Col17 int,Col18 int,Col19 int,Col20 int,Col21 int,Col22 int,Col23 int,Col24 int,Col25 int,Col26 int,Col27 int,Col28 int,Col29 int,Col30 int,Col31 int,Col32 int,Col33 int,col34 int) insert @tblselect 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 10,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 20,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 30,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34unionselect 40,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34 select SUM(Col1) Total,Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15,Col16,Col17,Col18,Col19,Col20,Col21,Col22,Col23,Col24,Col25,Col26,Col27,Col28,Col29,Col30 from @tblgroup by grouping sets ((),(Col1,Col2),(Col1,Col2,Col3),(Col1,Col2,Col3,Col4),(Col1,Col2,Col3,Col4,COL5),(Col2,Col3,Col4,Col5,Col6,Col7,Col8,Col9,Col10,Col11,Col12,Col13,Col14,Col15,Col16,Col17,Col18,Col19,Col20,Col21,Col22,Col23,Col24,Col25,Col26,Col27,Col28,Col29,Col30,col31,col32,col33))plz check after executing above query  its giving error plz lookinto my issue "Msg 10706, Level 16, State 1, Line 27Too many expressions are specified in the GROUP BY clause. The maximum number is 32 when grouping sets are supplied." </description><pubDate>Thu, 21 Feb 2013 11:34:35 GMT</pubDate><dc:creator>cooljagadeesh</dc:creator></item><item><title>RE: Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>Hello cooljagadeesh, Can you provide us with a little more detail please? What exactly are you trying to group? If you're just looking for basic information on grouping, there's a nice article by Craig Freedman.Link: [url]http://blogs.msdn.com/b/craigfr/archive/2007/10/11/grouping-sets-in-sql-server-2008.aspx[/url]</description><pubDate>Wed, 20 Feb 2013 16:18:45 GMT</pubDate><dc:creator>SQL_Enthusiast</dc:creator></item><item><title>Grouping sets</title><link>http://www.sqlservercentral.com/Forums/Topic1422228-392-1.aspx</link><description>Hi All,how to use the groupingsets to a query having more than 32 columns plz help out</description><pubDate>Wed, 20 Feb 2013 11:39:23 GMT</pubDate><dc:creator>cooljagadeesh</dc:creator></item></channel></rss>