select code,case substring(code,1,1) when 'C' then '' else 'P' end as PPD,case substring(code,1,1) when 'P' then '' else 'C' end as COLL,case substring(code,2,1) when 'C' then '' else 'P' end as PPD,case substring(code,2,1) when 'P' then '' else 'C' end as COLL from xx