Is there a way to not duplicate the group by clause when it is included in the select?
For example, one can do: Select x,y,z from mytable order by 1,2,3 If the clauses of x,y, and z are long complicated functions, this saves typing and mistakes. However, I am not aware of a typing saver for: Select f(x),g(y),avg(z) from MyTable group by f(x),g(y)
Any ideas?
Larger example:
SELECT DATEADD(HOUR,datepart(hour,inquirydate),cast(cast(inquirydate as date) as datetime)) as dayhour, COUNT(*) as qty, AVG(workms+queuems+0.0) as avgTimeMs FROM datalog WHERE inquirydate>'1/1/2014' GROUP BY DATEADD(HOUR,datepart(hour,inquirydate),cast(cast(inquirydate as date) as datetime))
Notice a large chunk of the above was repeated. When one repeats oneself, they tend to make mistakes.