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!

LIKE statement in CASE statement

757723Mar 15 2011 — edited Mar 15 2011
Hi,

I have a table called amounttagged as below

Amount Tag
10000 ABDCBD
20000 CBDADE
30000 CBDABD
40000 ABDADE

and my sql statement is as below,

select Amount, case when tag like '%ABD%' then 'ABD' else when tag like '%CBD%' then 'CBD' else 'ADE' end as tag
from amounttagged

The problem is when the tag is ABDCBD it will only be displayed for 'tag like '%ABD%' statement and the tag is only ABD. How can I make it to appear for both tag ABD and CBD?

Pls see example of result of sql
Amount Tag
10000 ABD
20000 CBD
30000 CBD
40000 ADE

How can I make the amount 10000 appear for tag CBD as well? Pls advise.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2011
Added on Mar 15 2011
4 comments
23,739 views