SELECT t1.PK, t1.id, t1.status, t2.status status2FROM TableName t1 INNER JOIN TableName t2 ON t1.id = t2.Id AND t1.PK<t2.PKWHERE status='01' and status2!='02'
SELECT * FROM Table1 t1 WHERE status = '01' AND NOT EXISTS ( SELECT 1 FROM table1 t2 WHERE status = '02' AND t1.id = t2.id )
Select * from table_1 Where status = '01' and id not in (SELECT distinct id from table_1 Where status = '02')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)