Вот полный пример того, как это сделать.У него проблема с комментарием, который я вставил в ваш вопрос.
create table #original (
Code int,
Amount float,
Expenditure varchar(20)
)
create table #output (
Code int,
LC float,
TE float
)
insert into #original values (10027, 5000, 'LOCAL CONVEYANCE')
insert into #original values (10027, 320, 'LOCAL CONVEYANCE')
insert into #original values (10116, 1589, 'TRAVEL EXPENSES')
insert into #original values (10095, 350, 'LOCAL CONVEYANCE')
insert into #original values (10095, 1215, 'TRAVEL EXPENSES')
insert into #output
select o.Code, o.Amount, NULL
from #original o
where o.Expenditure = 'LOCAL CONVEYANCE'
insert into #output
select o.Code, NULL, o.Amount
from #original o
where o.Expenditure = 'TRAVEL EXPENSES'
and o.Code not in (select Code from #output)
update #output
set TE = o.Amount
from #output p
inner join #original o on o.Code = p.Code and o.Expenditure = 'TRAVEL EXPENSES'
select * from #output
drop table #original
drop table #output