|
|
楼主 |
发表于 2026-1-20 16:31:32
|
显示全部楼层
销售订单流向
select '' as so_id,
sheet.distno as so_no,
sheet.execdate as so_time,
store.busno as enterprise_inner_code,
store.orgname as enterprise_name,
sheet_detail.makeno as so_batch_no,
case
when sheet.billcode in ('DIR', 'ADR') then
-1 * sheet_detail.wareqty
else
sheet_detail.wareqty
end as so_quantity,
sheet_detail.makedate as so_product_time,
sheet_detail.invalidate as so_effective_time,
prod.lastsaleprice as so_price,
prod.wareid as goods_in_sn,
prod.warename as goods_name,
prod.fileno as so_license,
prod.warespec as so_specifications,
prod.wareunit as so_unit,
prod.factoryname as so_manufacturer,
'其它渠道销售' as so_source
from h2.t_dist_h sheet
inner join h2.t_dist_d sheet_detail
on sheet.distno = sheet_detail.distno
inner join h2.v_ware prod
on sheet_detail.wareid = prod.wareid
and prod.compid = sheet.compid
inner join h2.s_busi store
on case
when sheet.billcode in ('DIR', 'ADR') then
sheet.srcbusno
else
sheet.objbusno
end = store.busno
and store.compid = sheet.compid
where prod.factoryname like '%北京%'
and sheet.billcode in ('DIR', 'DIS', 'ADR', 'ADD') |
|