declare @testdata table(id int,col1 varchar(20),col2 varchar(20)) insert into @testdata(id,col1,col2) select 1,'new','approved' union all select 2,'approved','commited' union all select 3,'commited','in progress' union all select 4,'new','approved' union all select 5,'new','approved' union all select 6,'new','approved' union all select 7,'approved','removed' select * from @testdata