You have not indicated the structure of the table but I can do this in Oracle (I don't use Sql Server):
create table investments
(
slno number primary key,
type char(1),
amount number
)
;
I insert some records:
insert into investments values (1, 'P', 10000);
insert into investments values (2, 'R', 8000);
insert into investments values (3, 'P', 5000);
insert into investments values (4, 'R', 4000);
insert into investments values (5, 'P', 2000);
insert into investments values (6, 'P', 6000);
insert into investments values (7, 'R', 3000);
The select query is:
select slno,
case type when 'P' then to_char(amount) else '---' end paid,
case type when 'R' then to_char(amount) else '---' end received,
sum(amount * case type when 'P' then 1 else -1 end) over (order by slno) invested
from investments
order by 1