Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Group By with Case Statement

Dory_ALMJul 18 2013 — edited Jul 18 2013

Hi

I have a query that I would like to return a different group by list dependent on a bind variable being passed in ? It seems easy but I cannot figure it out>

Example 1 if the :P380_COURIER_TYPE ='All'  I would like the group by to be "group by tour"  -- one column

Example 2 if the :P380_COURIER_TYPE <>'All' I would like the group by to be "group by tour,exp_del_channel"   --2 columns

select

Tour as "Tour"

,Exp_del_channel as "Courier Type"   -- this can be removed from the select statement as it is not required in the report.

,sum(pan_only) as "Pan Only"

from

VW_VOLUME_PREADVICE_REPORT vpa

where (:P380_COURIER_TYPE ='All' or exp_del_channel =:P380_COURIER_TYPE)

group by tour,exp_del_channel

This post has been answered by Sven W. on Jul 18 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2013
Added on Jul 18 2013
1 comment
550 views