if object_id('test') is not null
drop table test
go
create table test(in_detail_id int,scheduler_code varchar(15),scheduler_month int,pat_id varchar(15),aty_need decimal(10,4))
insert into test select 68,'Scheduler001',1,'Y005000033',6.0000
union all select 69,'Scheduler001',1,'SF20512',0.0000
union all select 70,'Scheduler001',1,'P005000010',0.0000
union all select 71,'Scheduler001',2,'P012000035',22.5000
union all select 72,'Scheduler001',2,'Y012000858',22.5000
union all select 73,'Scheduler001',3,'SF21936',0.0000
union all select 74,'Scheduler001',3,'P001000016',23.5200
union all select 75,'Scheduler001',3,'Y001000015',10.0800
go
select in_detail_id,scheduler_code,pat_id,case scheduler_month when 1 then cast(aty_need as varchar) else ''end as '1月',
case scheduler_month when 2 then cast(aty_need as varchar) else ''end as '2月',
case scheduler_month when 3 then cast(aty_need as varchar) else ''end as '3月',
case scheduler_month when 4 then cast(aty_need as varchar) else ''end as '4月',
case scheduler_month when 5 then cast(aty_need as varchar) else ''end as '5月',
case scheduler_month when 6 then cast(aty_need as varchar) else ''end as '6月',
case scheduler_month when 7 then cast(aty_need as varchar) else ''end as '7月',
case scheduler_month when 8 then cast(aty_need as varchar) else ''end as '8月',
case scheduler_month when 9 then cast(aty_need as varchar) else ''end as '9月',
case scheduler_month when 10 then cast(aty_need as varchar) else ''end as '10月',
case scheduler_month when 11 then cast(aty_need as varchar) else ''end as '11月',
case scheduler_month when 12 then cast(aty_need as varchar) else ''end as '12月'
from test