22,210
社区成员
发帖
与我相关
我的任务
分享
with t as (
select * ,1 sort
from 订单表 a
inner join 箱唛表 b on (a.目的国= b.目的国 and a.订单尾号=b.订单尾号 and b.箱唛规则=【目的国+订单尾号】)
union all
select * ,2 sort
from 订单表 a
inner join 箱唛表 b on (a.目的国= b.目的国 and a.运输方式=b.运输方式 and b.箱唛规则=【目的国+运输方式】)
),tt as (
select *,rn=ROW_NUMBER(partition by a.订单编号 order by sort)
from t
)
select * from tt where tt.rn=1