在这里插入代码片select distinct a.lot,sum(a.qty+0) qty from
(
select _lot1 lot,_qty1 qty from middle_box where (_lot1 <> '' and _lot1 is not null) and (_rel = 'M2032AH005' or _rel = 'M2032AH006' or _rel = 'M2032AH007' or _rel = 'M2032AH002' or _rel = 'M2032AH003')
union all
select _lot2 lot,_qty2 qty from middle_box where (_lot2 <> '' and _lot2 is not null) and (_rel = 'M2032AH005' or _rel = 'M2032AH006' or _rel = 'M2032AH007' or _rel = 'M2032AH002' or _rel = 'M2032AH003')
union all
select _lot3 lot,_qty3 qty from middle_box where (_lot3 <> '' and _lot3 is not null) and (_rel = 'M2032AH005' or _rel = 'M2032AH006' or _rel = 'M2032AH007' or _rel = 'M2032AH002' or _rel = 'M2032AH003')
) a group by a.lot
多个字段去重 多关联查
最新推荐文章于 2024-10-08 14:10:00 发布