select cc.*, bb.供应商 优选供应商 from ((SELECT c.ITEM供应商合并,c.ITEM, c.物料说明, c.SQE, c.供应商, c.PO,c.time from(select * from dbo.活动区间ITEM a where convert(varchar(10), time, 120) >= '2022-01-01' and convert(varchar(10), time, 120) <= '2022-05-16' )c group by c.ITEM供应商合并,c.ITEM, c.物料说明, c.SQE, c.供应商, c.PO,c.time)cc left join (select * from dbo.活动区间ITEM a where convert(varchar(10), time, 120) >= '2021-01-01' and convert(varchar(10), time, 120) <= '2021-12-31') bb on cc.ITEM = bb.ITEM where bb.供应商 is not null and cc.供应商 <> bb.供应商) SQLSERVER的 |