Somthing like this Declare @TimeSheet Table ([ID] Int Identity(1,1),job int,activity int,workfunction int,Hours int,comment varchar(10))Insert @TimeSheet Select 1, 1 , 1 , 2 , 'asa' Union AllSelect 2, 1 , 1 , 3 , 'sbsb' Union AllSelect 3, 2 , 2 , 5 , 'sdsa' Union AllSelect 4, 2 , 3 , 6 , 'fdgg' Update @TimeSheet Set Job = Case When Job In ( 1,2) Then 5 When Job In (3,4) Then 6 End -- Now update other details. Update t Set Hours = t.Hours+ f.hours,Comment = t.Comment + ',' + f.Comment From @TimeSheet tInner Join (Select * From @TimeSheet t1 Where [id] = (Select Max(id) From @TimeSheet t2 where t1.[job] =t2.[job])) fon t.job = f.job and t.[id] <> f.[id] -- Delete the unwanted records. delete t from @TimeSheet t where t.[id] = (select max([id]) from @timesheet t2 where t.[job] = t2.[job])Select * From @TimeSheet
Chirag