Link to home
Start Free TrialLog in
Avatar of Derek_Indianapolis
Derek_Indianapolis

asked on

How to properly use an IIF statement with multiple criterion?

I would like to write an IIF statement that converts the example query:

Location      Count
DN01 00 01      4
DN01 00 02      5
DN02 00 01      4
DW01 00 01      3
DW01 00 02      1
DW02 00 02      4
DW03 00 01      1

To convert the previous example to this:

Location      Count
NA10       4
NA10       2
WA01      3
WA01      1
WA02      4

Basically, Everytime it shows a  DN change to NA, Everytime it shows a DW change to WA.  Then also I only want to see the left 4 places after the text replacements take place.  I only have read access to the host data system, so I can not change the locations in the system.
Avatar of Binuth
Binuth
Flag of India image

select
left(replace(replace(Location,'DN','NA'),'DW','WA'),4) AS Location,Count
from <TableName>
ASKER CERTIFIED SOLUTION
Avatar of Mark Wills
Mark Wills
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial