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!

case statement is giving duplicate record.

syed haiderAug 28 2018 — edited Aug 28 2018

I have a following code snippet. This is giving me duplicate records.

select state_id,

case when  upper(location) = 'CLE' then 'Cleveland'

     when  upper(location) = 'PHL' then 'Philadelphia'

end label_report_location

from states

result:

state_id        label_report_location

1                    Cleveland

1                  

2                    Philadelphia

2                   

I strongly feel it's due to how my case statement is set up. When I remove the case statement, then I don't get any duplicates.

Any suggestions as to how I can improvise my case statement, so that same record doesn't get repeated twice.

Thank you in advance!

Sorry about the confusion. I've edited the output. I also resolved the problem by stating where label_report_location is not null. Thanks for everyone's feedback. I appreciate it.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2018
Added on Aug 28 2018
7 comments
3,147 views