select ROW_NUMBER() over(order by dbo.computer_3_5.stud_id)[ID],
MIN(case when dbo.computer_3_5.term='Term-1' then term end ) [Term1],
MIN(case when dbo.computer_3_5.term='Term-1' and total is not null then total else '0' end ) [total1],
MIN(case when dbo.computer_3_5.term='Term-2' then term end ) [Term2],
MIN(case when dbo.computer_3_5.term='Term-2' and total is not null then total else '0' end ) [total2],
dbo.student_master.roll_no, dbo.student_master.stud_name,dbo.computer_3_5.std_id, dbo.computer_3_5.sec_id,dbo.computer_3_5.y_id from dbo.computer_3_5 INNER JOIN dbo.student_master ON dbo.computer_3_5.stud_id = dbo.student_master.stud_id
group by dbo.computer_3_5.stud_id,dbo.student_master.roll_no, dbo.student_master.stud_name,dbo.computer_3_5.std_id, dbo.computer_3_5.sec_id,dbo.computer_3_5.y_id
and below is my table
CREATE TABLE [dbo].[computer_3_5](
[id] [bigin ...
Go to the complete details ...