This?SELECT MAX([NoId]) AS [NoID] , [MileStoneId] , [description] , [user]FROM ( SELECT DISTINCT case when (IDStatus = Code ) then ID else 0 end as NoID , case when (IDStatus = Code) then IDStatus else Code end as MileStoneID, Description, User from table1 , table2 where Table_Name = 'ID_Status' and Code != 'NOTSTARTED' and Description != 'Started' and UserID ='xYZ' ) aGROUP BY [MileStoneId] , [description] , [user]
Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION