finish work on customer swap, start testing this
This commit is contained in:
parent
b487430057
commit
f7f26b2804
@ -112,9 +112,9 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
|
|||||||
FROM
|
FROM
|
||||||
rlarp.osm_pool o
|
rlarp.osm_pool o
|
||||||
CROSS JOIN log
|
CROSS JOIN log
|
||||||
INNER JOIN swap ON
|
INNER JOIN cust c ON
|
||||||
swap.bill_to = SUBSTRING(o.bill_cust_descr,1,8)
|
c.billto = SUBSTRING(o.bill_cust_descr,1,8)
|
||||||
swap.bill_to = SUBSTRING(o.ship_cust_descr,1,8)
|
AND c.shipto = SUBSTRING(o.ship_cust_descr,1,8)
|
||||||
WHERE
|
WHERE
|
||||||
-----------------scenario----------------------------
|
-----------------scenario----------------------------
|
||||||
where_clause
|
where_clause
|
||||||
@ -125,13 +125,13 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
|
|||||||
,o.dplt plnt ---master data
|
,o.dplt plnt ---master data
|
||||||
,o.promo --history date mix
|
,o.promo --history date mix
|
||||||
,terms
|
,terms
|
||||||
,bill_cust_descr --history cust mix
|
,COALESCE(c.bill_r||' - '||c.bill_dba,bill_cust_descr) bill_cust_descr
|
||||||
,ship_cust_descr --history cust mix
|
,COALESCE(c.ship_r||' - '||c.ship_dba,ship_cust_descr) ship_cust_descr
|
||||||
,dsm
|
,dsm
|
||||||
,quota_rep_descr --master data
|
,quota_rep_descr --master data
|
||||||
,director
|
,director
|
||||||
,billto_group --master data
|
,COALESCE(c.bill_dba,billto_group) billto_group
|
||||||
,shipto_group
|
,COALESCE(c.ship_dba,shipto_group) shipto_group
|
||||||
,chan --master data
|
,chan --master data
|
||||||
,chansub
|
,chansub
|
||||||
,chan_retail
|
,chan_retail
|
||||||
@ -174,12 +174,11 @@ target AS (SELECT $$swap_doc$$::jsonb swap)
|
|||||||
,o.module
|
,o.module
|
||||||
FROM
|
FROM
|
||||||
remove o
|
remove o
|
||||||
LEFT OUTER JOIN bill ON
|
INNER JOIN cust c ON
|
||||||
bill.billto = rtrim(substring(o.bill_cust_desrc,1,8))
|
c.billto = SUBSTRING(o.bill_cust_descr,1,8)
|
||||||
LEFT OUTER JOIN ship ON
|
AND c.shipto = SUBSTRING(o.ship_cust_descr,1,8)
|
||||||
ship.shipto = rtrim(substring(o.ship_cust_desrc,1,8))
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
--select bill_cust_descr, ship_cust_descr, sum(value_usd) from (SELECT * FROM remove UNION ALL SELECT * FROM repl) x group by bill_cust_descr, ship_cust_descr
|
||||||
,ins AS (
|
,ins AS (
|
||||||
INSERT INTO rlarp.osm_pool SELECT * FROM remove UNION ALL SELECT * FROM repl RETURNING *
|
INSERT INTO rlarp.osm_pool SELECT * FROM remove UNION ALL SELECT * FROM repl RETURNING *
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user