|
select
L01, L03, A05 , case when SUBSTRING(COLLECTION,2,2)='01' and COLL5=1 then 3 when SUBSTRING(COLLECTION,2,2)='02' and COLL5=1 then 6 when SUBSTRING(COLLECTION,2,2)='03' and COLL5=1 then 9 when SUBSTRING(COLLECTION,2,2)='04' and COLL5=1 then 12 when SUBSTRING(COLLECTION,2,2)='05' and COLL5=1 then 12 when SUBSTRING(COLLECTION,2,2)='01' and COLL13=1 then 1 when SUBSTRING(COLLECTION,2,2)='02' and COLL13=1 then 2 when SUBSTRING(COLLECTION,2,2)='03' and COLL13=1 then 3 when SUBSTRING(COLLECTION,2,2)='04' and COLL13=1 then 4 when SUBSTRING(COLLECTION,2,2)='05' and COLL13=1 then 5 when SUBSTRING(COLLECTION,2,2)='06' and COLL13=1 then 6 when SUBSTRING(COLLECTION,2,2)='07' and COLL13=1 then 7 when SUBSTRING(COLLECTION,2,2)='08' and COLL13=1 then 8 when SUBSTRING(COLLECTION,2,2)='09' and COLL13=1 then 9 when SUBSTRING(COLLECTION,2,2)='10' and COLL13=1 then 10 when SUBSTRING(COLLECTION,2,2)='11' and COLL13=1 then 11 when SUBSTRING(COLLECTION,2,2)='12' and COLL13=1 then 12 when SUBSTRING(COLLECTION,2,2)='13' and COLL13=1 then 13 end as PERIOD
from ( select
L01, L03, A05, COLLECTION , case when LEFT(COLLECTION,1) in ('W','S') then 1 else 0 end as COLL13 , case when LEFT(COLLECTION,1) in ('C','F','U') then 1 else 0 end as COLL5
from
ILR0910_E_AIMS )T |