Declare @table table(Parameter_ID int,Parameters_Name varchar(10),Target_Value int,GroupID int,Sequence_No int)
insert into @table values
(1, 'Para_1', 1000, 2, 1),
(2, 'Para_2', 2000, 2, 2),
(3, 'Para_3', 3000, 2, 3),
(4, 'Para_4', NULL, 2, 4),
(5, 'Para_5', 5000, 2, 5),
(6, 'Para_1', 1450, 3, 1),
(7, 'Para_2', 1200, 3, 2),
(8, 'Para_4', NULL, 3, 3),
(9, 'Para_5', 3000, 3, 4),
(10, 'Para_2', 3000, 4, 1),
(11, 'Para_3', 4000, 4, 2),
(12, 'Para_4', NULL, 4, 3)
select *,sum(Target_Value)over(partition by GroupID order by Sequence_No)Tot from @table order by Parameter_ID