SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Infer Group By

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
Infer Group By
Author Message
judahr



Joined: 09 Mar 2007
Posts: 319
Country: United States

Post Infer Group By Reply with quote
I've often wanted the ability to select an inferred Group By. Imagine you have a query:

Code:
Select Field1, Count(*) From dbo.Table1


If I type in Group by, it would be awesome if it allowed me to click enter and put in Field1. Or more complex:


Code:
Select Field1, Field2, Field3, OtherValue = Left(Field4, 5), Count(*) From dbo.Table1



If I type in Group by, it would be awesome if it allowed me to click enter and put in "Field1, Field2, Field3, Left(Field4, 5)". You'd have to work out the Field = vs the As, but it is doable. Basically it is grabbing the select, ignoring the aggregates and column name aliases.
Fri Nov 15, 2013 5:30 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7843

Post Reply with quote
It's fairly easy to do for a single column using a code snippet

Create a new code snippet grpby
In the code of the snipped put something like

Code:
SELECT $OBJECT(ins_column)$, count(*)
FROM $OBJECT()$
GROUP BY $OBJECT(ins_column)$
ORDER BY 1

Fri Nov 15, 2013 6:15 pm View user's profile Send private message
judahr



Joined: 09 Mar 2007
Posts: 319
Country: United States

Post Reply with quote
Cool, but its never just one field.
Mon Nov 18, 2013 9:57 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Good idea!

+1
Tue Nov 19, 2013 4:00 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7843

Post Reply with quote
I have entered an enhancement request to enable selection of multiple columns using $OBJECT(ins_column)$ macro
Tue Nov 19, 2013 8:31 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.