Попробуйте с условной агрегацией:
declare @tmp table
(
[Date] date,
Account int,
Head varchar(50),
D_C char(1),
TxnID int,
AmCode char(2),
Amount int
)
insert into @tmp
values
('2019-05-15', 123, 'Savings', 'D', 5, 'SV', 150)
,('2019-05-15', 123, 'Cash' , 'C', 5, 'SV', 150)
,('2019-05-16', 367, 'Loan' , 'D', 6, 'LN', 200)
,('2019-05-16', 367, 'Cash' , 'C', 6, 'LN', 200)
select
[Date]
, Account
, max(case when D_C='D' then Head end )as [D Head]
, max(case when D_C='C' then Head end )as [C Head]
, TxnID
, AmCode
, Amount
From @tmp
group by [Date], Account, TxnID, AmCode, Amount
Результаты: