|
|
|
Re: eliminating group by [message #413202 is a reply to message #413201] |
Tue, 14 July 2009 15:04 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
What kind of question is this?
Do you think GROUP BY is only there to make the query looks pretty?
If you can remove GROUP BY clause and the result does not change, then GROUP BY would be first used.
Regards
Michel
[Updated on: Tue, 14 July 2009 15:05] Report message to a moderator
|
|
|
|
Re: eliminating group by [message #413229 is a reply to message #413203] |
Tue, 14 July 2009 22:03 |
rleishman
Messages: 3728 Registered: October 2005 Location: Melbourne, Australia
|
Senior Member |
|
|
Sounds to me like this could be one of two things:
It could be one of the stupidest interview questions ever - where the interviewer want to know whether the applicant understands Analytic Functions.
Generally speaking, an aggregation (GROUP BY) can be simulated using an Analytic Function and a filtered inline view. The only caveat is that there is no point, because it is always harder to understand and less efficient.
Alternatively, this could be the result of poor performing SQL and a helpful DBA telling a hapless programmer to "eliminate the GROUP BY" to make it run faster. If so, there is no magic way to do the job of a GROUP BY any faster.
Ross Leishman
|
|
|
|
|