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 ««12

use column in Group By, but Hide column from the results set Expand / Collapse
Author
Message
Posted Thursday, September 20, 2012 6:26 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Today @ 2:53 AM
Points: 84, Visits: 208
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
Post #1361911
Posted Thursday, September 20, 2012 7:25 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 4:16 PM
Points: 1,091, Visits: 2,205
siggemannen (9/20/2012)
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

Why would you want that?
You would be missing information.



Luis C.
Please don't trust me, test the solutions I give you before using them.
Forum Etiquette: How to post data/code on a forum to get the best help
Post #1361951
Posted Thursday, September 20, 2012 7:28 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 1:39 AM
Points: 4,328, Visits: 9,667
siggemannen (9/20/2012)
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


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.


____________________________________________________________________________________________

Help us to help you. For better, quicker and more focused answers to your questions, consider following the advice in this link:

http://www.sqlservercentral.com/articles/Best+Practices/61537/

If you are asking for help and your post does not contain a question, you should expect responses which do not contain any answers. Put a question mark in there somewhere - it's not rocket science.
Post #1361956
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse