select 物项编码 from 表名 where 状态='合格'
--如何查询表中状态为全部合格的物项编码? --物料编号不存在不合格的,就是全部合格的 select * from 表 a where not exists(select 1 from 表 where 物项编码=a.物项编码 and 状态='不合格')