Skip to Main Content

Oracle Database Discussions

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!

skip condition in where clause for certain groups, is it possible?

TinaMay 23 2018 — edited May 29 2018

Hi Gurus,

   I am trying to write one query which is something similar structure below.

   I am trying to run 'condition_3' only for certain groups (lets say for group_num in ( 'aaa', 'bbb', 'ccc'))

   For other groups I don't need that condition.

   select col1, col2 ,group_num, .....

             from tab1, tab2, tab3

         where condition_1

                    and condition_2

                    and condition_3 ;

   Is there a way to obtain that in a same select by case statement? or any other way?

   select col1, col2 ,group_num, .....

             from tab1, tab2, tab3

         where condition_1

                    and condition_2

                    and case when group_num in ('aaa','bbb','ccc') then

                                    1=1

                            else  condition_3

                            end;

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 26 2018
Added on May 23 2018
7 comments
613 views