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.
In our SQL Prompt 6.5 beta we now suggest an “All non-aggregated columns” item after a GROUP BY clause which will expand to all the non-aggregated columns being selected. We also suggest aggregates first in a HAVING clause. You can find out more and download the beta from https://forums.red-gate.com/viewtopic.php?f=169&t=78239
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