select t.objid, test.仓库, t.物资编码 from test right outer join (select distinct objid, 物资编码 from test group by objid, 物资编码) t on test.objid=t.objid and test.物资编码=t.物资编码