Home » SQL & PL/SQL » SQL & PL/SQL » Problem in doing group by in query (Oracle 10g)
Problem in doing group by in query [message #289729] Tue, 25 December 2007 22:44 Go to next message
aruna.mishra
Messages: 1
Registered: December 2007
Junior Member
Hi,

I want to do group by on day column in the following query

select day,id from table1 group by day

As i know that group by can only be done if there is any aggregate function in the query. Thats why my query is giving error.

Is there any other way that can solve my problem?

Thanks
Aruna
Re: Problem in doing group by in query [message #289737 is a reply to message #289729] Tue, 25 December 2007 23:33 Go to previous messageGo to next message
Barbara Boehmer
Messages: 8631
Registered: November 2002
Location: California, USA
Senior Member
Please review the forum guide at the top of the screen or using the link below and provide the required information, such as create table and insert statements for sample data and the results that you want based on that data and your Oracle version.


http://www.orafaq.com/forum/t/88153/0/
Re: Problem in doing group by in query [message #289756 is a reply to message #289729] Wed, 26 December 2007 01:04 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
If you want to group by day then you don't want and can't have id.
If you have id then you want to group by day AND id.
You can group even if there is no group function (but in this case it is equivalent and better to use DISTINCT).

Regards
Michel
Re: Problem in doing group by in query [message #289793 is a reply to message #289729] Wed, 26 December 2007 02:50 Go to previous message
spmano1983
Messages: 269
Registered: September 2007
Senior Member
Hi,

try this

select day,id from table1 group by day,id

Mano
Previous Topic: ORA-29284
Next Topic: About the query...
Goto Forum:
  


Current Time: Mon Dec 05 15:15:03 CST 2016

Total time taken to generate the page: 0.11855 seconds