 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
judahr
Joined: 09 Mar 2007 Posts: 319 Country: United States |
|
Infer Group By |
|
I've often wanted the ability to select an inferred Group By. Imagine you have a query:
 |
 |
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:
 |
 |
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 |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
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
 |
 |
SELECT $OBJECT(ins_column)$, count(*)
FROM $OBJECT()$
GROUP BY $OBJECT(ins_column)$
ORDER BY 1 |
|
|
Fri Nov 15, 2013 6:15 pm |
|
 |
judahr
Joined: 09 Mar 2007 Posts: 319 Country: United States |
|
|
|
Cool, but its never just one field.
|
|
Mon Nov 18, 2013 9:57 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Good idea!
+1
|
|
Tue Nov 19, 2013 4:00 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I have entered an enhancement request to enable selection of multiple columns using $OBJECT(ins_column)$ macro
|
|
Tue Nov 19, 2013 8:31 am |
|
 |
|
|
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
|
|
|