select b.包裹id,b.包裹明细id,a.包裹号,'退换' 售后状态
from x_tm_package a join x_tm_package_detail b on a.包裹id = b.包裹id
where 退换数量 <> 0
union all
select b.包裹id,b.包裹明细id,a.包裹号,'换货' 售后状态
from x_tm_package a join x_tm_package_detail b on a.包裹id = b.包裹id
where 换货数量 <> 0
union all
select b.包裹id,b.包裹明细id,a.包裹号,'拒收' 售后状态
from x_tm_package a join x_tm_package_detail b on a.包裹id = b.包裹id
where 拒收数量 <> 0
union all
select b.包裹id,b.包裹明细id,a.包裹号,'正常' 售后状态
from x_tm_package a join x_tm_package_detail b on a.包裹id = b.包裹id
where 数量 <> 0
order by 包裹id,包裹明细id
------解决方案--------------------