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.