LIKE statement in CASE statement
757723Mar 15 2011 — edited Mar 15 2011Hi,
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.