Home » SQL & PL/SQL » SQL & PL/SQL » group by problem (oracle 10g r2)
group by problem [message #444967] Thu, 25 February 2010 00:02 Go to next message
abhi_shakya
Messages: 50
Registered: September 2009
Location: Nepal
Member
Select max(sal),CASE deptno when 10 then 'Accounts'

When 20 then 'Sales'

When 30 then 'R&D'

Else "Unknown' end as post

From emp
group by post;



when running this query,returns error...
can i use expression alias in group by or not...
Re: group by problem [message #444968 is a reply to message #444967] Thu, 25 February 2010 00:09 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
1/ Please follow Posting Guidelines - OraFAQ Forum Guide
2/ Please provided DDL (CREATE TABLE ......) for ALL tables involved.
3/ Please provided DML (INSERT INTO .......) for Test data.
4/ Please provided expected/desired results.
5/ Please Preview Message / Spell-Check Before Posting.
Re: group by problem [message #444969 is a reply to message #444967] Thu, 25 February 2010 00:09 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
It would be helpful if you followed Posting Guidelines - http://www.orafaq.com/forum/t/88153/0/

>when running this query,returns error...
ERROR? What Error? I do not see any error.
Re: group by problem [message #444970 is a reply to message #444967] Thu, 25 February 2010 00:10 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
Error message returned by Oracle will clearly solve your doubt.
Just read it again.

regards,
Delna
Re: group by problem [message #444971 is a reply to message #444967] Thu, 25 February 2010 00:10 Go to previous messageGo to next message
rahulvb
Messages: 924
Registered: October 2009
Location: Somewhere Near Equator.
Senior Member
abhi_shakya wrote on Thu, 25 February 2010 00:02

when running this query,returns error...
can i use expression alias in group by or not...


what error I dont see any ?
Re: group by problem [message #444972 is a reply to message #444967] Thu, 25 February 2010 00:13 Go to previous messageGo to next message
abhi_shakya
Messages: 50
Registered: September 2009
Location: Nepal
Member
it says we cannot use column alias in group by clause.
now how shud i solve it...
Re: group by problem [message #444974 is a reply to message #444972] Thu, 25 February 2010 00:14 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>it says we cannot use column alias in group by clause.
>now how shud i solve it...


too bad CUT & PASTE are broken for you.
Re: group by problem [message #444975 is a reply to message #444972] Thu, 25 February 2010 00:21 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
abhi_shakya wrote on Thu, 25 February 2010 07:13
it says we cannot use column alias in group by clause.
now how shud i solve it...

By repeating the expression or using an inline view.

Regards
Michel

Re: group by problem [message #444985 is a reply to message #444975] Thu, 25 February 2010 01:21 Go to previous message
abhi_shakya
Messages: 50
Registered: September 2009
Location: Nepal
Member
thanx michel
Previous Topic: QUERY FOR GROUPING AND COUNT
Next Topic: retrieve one value for phone number
Goto Forum:
  


Current Time: Sat Dec 10 17:02:18 CST 2016

Total time taken to generate the page: 0.06543 seconds