日期:2014-05-17 浏览次数:20440 次
id sn process status
1 001 p1 pass
2 001 p2 fail
3 001 p2 fail
4 001 p2 pass
5 001 p3 fail
6 001 p3 pass
7 001 p4 fail
id sn process status
7 001 p4 fail
6 001 p3 pass
4 001 p2 pass
1 001 p1 pass
SELECT *
FROM TB A
WHERE NOT EXISTS(SELECT 1 FROM TB B WHERE A.sn = B.sn AND A.id < b.id AND A.process = b.process)
and A.sn = '001' --加上你的条件即可。