SELECT PC_COMP_CODE,
\'R\',
PC_RESUB_REF,
DECODE(PC_SL_LDGR_CODE, \'02\', \'DR\', \'CR\'),
PC_DEPT_NO DEPT,
\'\', --PC_DEPT_NO,
If I understand the question correctly, you want the equivalent of decode but in T-SQL
Select YourFieldAliasName =
CASE PC_SL_LDGR_CODE
WHEN '02' THEN 'DR'
ELSE 'CR'
END
In my Case I used it in a lot of places first example if you have 2 values for select statement like gender (Male or Female) then use the following statement:
SELECT CASE Gender WHEN 'Male' THEN 1 ELSE 2 END AS Gender
If there is more than one condition like nationalities you can use it as the following statement:
SELECT CASE Nationality
WHEN 'AMERICAN' THEN 1
WHEN 'BRITISH' THEN 2
WHEN 'GERMAN' THEN 3
WHEN 'EGYPT' THEN 4
WHEN 'PALESTINE' THEN 5
ELSE 6 END AS Nationality