SQL查询统计问题,where后面的条件

图片说明
这是Select Distinct Weldercode,jointno,ResultB from NDT_Record 查询后的结果,我想去掉有有不合格的记录的相同jointno的记录where后面该怎么写? 因为有不合格,所以查询后结果5,6条记录就没有了,


Select Distinct Weldercode,jointno,ResultB from NDT_Record A where not exist(select 1 from NDT_Record where Weldercode=A.Weldercode AND jointno=A.jointno AND ResultB='不合格')

先查不合格的join...
然后删除所有join...

Select A.Distinct Weldercode,A.jointno,A.ResultB from NDT_Record A where A.ResultB<>'不合格';

有兴趣可以看看关于mysql怎样优化WHERE子句 http://www.data.5helpyou.com/article270.html