﻿<?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)  / use column in Group By, but Hide column from the results set / 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>Tue, 18 Jun 2013 14:52:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]siggemannen (9/20/2012)[/b][hr]These kind of queries have real usage, for example if you want to preserve "duplicate rows" of Col1, Col2, which cannot be preserved if you only Group By Col1[/quote]Grouping By something which is not in the select is fine, I'm sure there are plenty of uses for that.But the original requirement - to include a column in select and in group by but then not to display it - is not so fine. I cannot think of a single use for that, other than as an example for a 'how to write superfluous SQL' book.</description><pubDate>Thu, 20 Sep 2012 07:28:46 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]siggemannen (9/20/2012)[/b][hr]These kind of queries have real usage, for example if you want to preserve "duplicate rows" of Col1, Col2, which cannot be preserved if you only Group By Col1[/quote]Why would you want that?You would be missing information.</description><pubDate>Thu, 20 Sep 2012 07:25:57 GMT</pubDate><dc:creator>Luis Cazares</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>These kind of queries have real usage, for example if you want to preserve "duplicate rows" of Col1, Col2, which cannot be preserved if you only Group By Col1</description><pubDate>Thu, 20 Sep 2012 06:26:40 GMT</pubDate><dc:creator>siggemannen</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]Phil Parkin (9/19/2012)[/b][hr][quote][b]preetid2 (9/19/2012)[/b][hr]Thanks Phil! this worked perfect![/quote]I feel like I have entered a parallel universe.:alien:[/quote]I knew that! Your avatar makes everything right! What a solution! :hehe::hehe::hehe:</description><pubDate>Wed, 19 Sep 2012 14:12:12 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]preetid2 (9/19/2012)[/b][hr]Thanks Phil! this worked perfect![/quote]I feel like I have entered a parallel universe.:alien:</description><pubDate>Wed, 19 Sep 2012 13:45:15 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>Thanks Phil! this worked perfect!</description><pubDate>Wed, 19 Sep 2012 13:38:59 GMT</pubDate><dc:creator>preetid2</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>You get too complicated. This should work.This will also give incomplete information on how the groups are made.[code="sql"]SELECT Col1, Count(*) AS Count_Rec           FROM MyTable           GROUP BY Col1, Col2[/code]</description><pubDate>Wed, 19 Sep 2012 12:51:36 GMT</pubDate><dc:creator>Luis Cazares</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]Phil Parkin (9/19/2012)[/b][hr][quote][b]Eugene Elutin (9/19/2012)[/b][hr]Yes it is possible, but what it will give you?[code="sql"]SELECT Col1, Count_RecFROM (SELECT Col1, Col2, Count(*) AS Count_Rec           FROM MyTable           GROUP BY Col1, Col2) aq[/code][/quote]Haha, what a fantastically useful query this would be :-D[/quote]Who knows, who knows... :hehe:</description><pubDate>Wed, 19 Sep 2012 11:45:51 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]Eugene Elutin (9/19/2012)[/b][hr]Yes it is possible, but what it will give you?[code="sql"]SELECT Col1, Count_RecFROM (SELECT Col1, Col2, Count(*) AS Count_Rec           FROM MyTable           GROUP BY Col1, Col2) aq[/code][/quote]Haha, what a fantastically useful query this would be :-D</description><pubDate>Wed, 19 Sep 2012 10:30:02 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>Can you give an example of what you're thinking of?</description><pubDate>Wed, 19 Sep 2012 10:24:35 GMT</pubDate><dc:creator>laurie-789651</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>Yes it is possible, but what it will give you?[code="sql"]SELECT Col1, Count_RecFROM (SELECT Col1, Col2, Count(*) AS Count_Rec           FROM MyTable           GROUP BY Col1, Col2) aq[/code]</description><pubDate>Wed, 19 Sep 2012 10:20:12 GMT</pubDate><dc:creator>Eugene Elutin</dc:creator></item><item><title>RE: use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>[quote][b]preetid2 (9/19/2012)[/b][hr]Is this possible in sql server 2008?I want to use the column in the select, and group by. But want to hide the column from the results set?[/quote]No. If you select a column, it will appear.</description><pubDate>Wed, 19 Sep 2012 10:18:36 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>use column in Group By, but Hide column from the results set</title><link>http://www.sqlservercentral.com/Forums/Topic1361480-392-1.aspx</link><description>Is this possible in sql server 2008?I want to use the column in the select, and group by. But want to hide the column from the results set?</description><pubDate>Wed, 19 Sep 2012 10:13:50 GMT</pubDate><dc:creator>preetid2</dc:creator></item></channel></rss>