Home » SQL & PL/SQL » SQL & PL/SQL » eliminating group by (oracle9i, Windows XP..SP2)
eliminating group by [message #413199] Tue, 14 July 2009 14:40 Go to next message
gaytri_25
Messages: 6
Registered: July 2009
Location: mumbai
Junior Member

if we used GROUP BY clause in our SQL query...
How can we eliminate it from our query??
Re: eliminating group by [message #413200 is a reply to message #413199] Tue, 14 July 2009 14:45 Go to previous messageGo to next message
ThomasG
Messages: 3212
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
You could use the "del" key.
Re: eliminating group by [message #413201 is a reply to message #413200] Tue, 14 July 2009 14:54 Go to previous messageGo to next message
gaytri_25
Messages: 6
Registered: July 2009
Location: mumbai
Junior Member

While eliminating GROUP BY clause whatever we get output should not change.

So tell me how to eliminate it without affecting output whatever we got from GROUP BY clause?
Re: eliminating group by [message #413202 is a reply to message #413201] Tue, 14 July 2009 15:04 Go to previous messageGo to next message
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 #413203 is a reply to message #413200] Tue, 14 July 2009 15:10 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
ThomasG wrote on Tue, 14 July 2009 15:45
You could use the "del" key.


Or not typing it in the first place. Less key strokes.
Re: eliminating group by [message #413229 is a reply to message #413203] Tue, 14 July 2009 22:03 Go to previous messageGo to next message
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
Re: eliminating group by [message #413287 is a reply to message #413229] Wed, 15 July 2009 02:28 Go to previous messageGo to next message
gaytri_25
Messages: 6
Registered: July 2009
Location: mumbai
Junior Member

Thanks ..I'm satisfied with your answer. It was an interview question asked to me.
Re: eliminating group by [message #413290 is a reply to message #413287] Wed, 15 July 2009 02:33 Go to previous message
ThomasG
Messages: 3212
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Then I definitely would think twice about accepting a job there. Razz
Previous Topic: date in varchar column
Next Topic: weekly interval partitioning
Goto Forum:
  


Current Time: Tue Dec 03 18:53:16 CST 2024