Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decode with group by

Status
Not open for further replies.

raddycal

Programmer
Nov 27, 2006
16
US
I have a select stmt. with decode and a sum. when I put the decode in the group by clause, it says "not a group by expression". when I put the columns from the decode in the group by clause, it says "not a group by expression".
when I put the alias for the decoded value in the group by
clause, it says "not a group by expression". how do I fix this?

thanks

RH
 
i wonder if you would be so kind as to re-post this question in the oracle forum (as i believe DECODE is oracle only)

this is the ANSI SQL forum

r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
 
r937 is correct - DECODE is an Oracle beast, so this should be in the appropriate Oracle forum. With that said, I would also note that the following works fine:
Code:
select decode(open_flag, 'Y','Yes','No'), count(*)
from oe_order_headers_all 
group by decode(open_flag, 'Y','Yes','No');
so I believe this is how you fix it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top