Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem using Group By with a SQL Select
Message
From
08/08/2002 10:13:26
 
 
To
All
General information
Forum:
Oracle
Category:
Reports
Title:
Problem using Group By with a SQL Select
Miscellaneous
Thread ID:
00687500
Message ID:
00687500
Views:
44
Hi, has anyone got any idea on how I can use a DECODE within a select statement that includes a grouping function. I can only give the DECODE field an alias and you can't use alias's in the Group By clause. Yet, I have to have the Group By clause for the fields that don't use a grouping function or I get the error 'Not a group by expression'. If I try to use the alias in the Group By I get 'invalid column name'. Example code:

select order_header.client_id as clientid,
DECODE('Shipped', 'Hold', order_header.ORDER_DATE, 'Shipped', order_header.DELIVER_BY_DATE, NULL) as TheDate,
count(order_header.FROM_SITE_ID)
from order_header
group by client_id, client_id, TheDate

The above statement will give me the error 'invalid column name' on TheDate in the group by clause.
Next
Reply
Map
View

Click here to load this message in the networking platform