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!

in Where Clause if found first match ignore next

RamiahRAGUSep 19 2017 — edited Sep 20 2017

In my below query when i pass COUNTRY value as SG i'm getting NAME ='CCC'  which is correct.

same time when i pass COUNTRY value as UK i wanted result as NAME=BBB and i dont want the next row ( it shows 'ccc' also)

WITH T AS (SELECT 'AAA' NAME , 'US' COUNTRY FROM DUAL UNION ALL

            SELECT 'BBB' NAME , 'UK' COUNTRY FROM DUAL UNION ALL

            SELECT 'CCC' NAME , 'OTHERS' COUNTRY FROM DUAL

            )

SELECT T.* FROM T

WHERE (COUNTRY = 'UK' OR COUNTRY='OTHERS')

--WHERE (COUNTRY = 'SG' OR COUNTRY='OTHERS')

--WHERE (CASE WHEN COUNTRY = 'SG' THEN COUNTRY ELSE 'OTHERS' END) ='SG'

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2017
Added on Sep 19 2017
16 comments
1,118 views