How to find percentage is BCOP-201(A)/BCOP-201(D) as 'P' for all columns
select Rollno, Name,
sum(case when scode = 'BCOP-201' then status else 0 end) as 'BCOP-201(A)',
(select sum(status) from msta where rollno = 777 and scode = 'BCOP-201') as 'BCOP-201(D)',
sum(case when scode = 'BCOP-202' then status else 0 end) as 'BCOP-202(A)',
(select sum(status) from msta where rollno = 777 and scode = 'BCOP-202') as 'BCOP-202(D)',
sum(case when scode = 'BCOP-203' then status else 0 end) as 'BCOP-203(A)',
(select sum(status) from msta where rollno = 777 and scode = 'BCOP-203') as 'BCOP-203(D)',
sum(case when scode = 'BCOP-204' then status else 0 end) as 'BCOP-204(A)',
(select sum(status) from msta where rollno = 777 and scode = 'BCOP-204') as 'BCOP-204(D)',
sum(case when scode = 'BCOP-205' then status else 0 end) as 'BCOP-205(A)',
(select sum(status) from msta where rollno = 777 and scode = 'BCOP-205') as 'BCOP-205(D)',
sum(case when scode = 'BCOP-206' then status else 0 end) as 'BCOP-206(A)',
(select sum(status) from msta where rollno = 777 and scode = 'BCOP-206') as 'BCOP-206(D)'
from msta
where rollno <> 777 and doa>=@tfdate and doa<=@ttdate and section='Nil' and semester='Sem-2'
group by rollno, name