Automatically generate the GROUP BY column list from the SELECT list
Typically, the GROUP BY column list is exactly the same as the SELECT list except the aggregates and any constants included. I usually wind up using a copy & paste, which is always a hassle, especially if it is a complex query. It always seemed to me that the GROUP BY list should be optional in the SQL standard. But short of a standard change followed by implementation changes, it would be nice to at least have it defaulted for me.
By the same token, the HAVING statement could (optionally) prepopulate with (one of) the aggregate(s) from the select list. But the GROUP BY list is usually the main hassle.
In fact, many of my statements with a GROUP BY clause, will have the same column list in SELECT, GROUP BY, and ORDER BY (if I include an ORDER BY), and others will order by the aggregate - usually in descending order.
This is included in SQL Prompt 6.5 which you can download from http://www.red-gate.com/products/sql-development/sql-prompt/
-
Tore Bostrup commented
Intellisense option as in http://redgate.uservoice.com/forums/94413-sql-prompt-feature-suggestions/suggestions/1605189-group-order-by-suggestions would be fine. The votes should probably be consolidated for these two and this description could be considered a comment to the other one.
-
Aaron Bauman commented