use inbound segment to hook with exisiting baseline data

This commit is contained in:
Paul Trowbridge 2021-05-12 11:46:02 -04:00
parent 4c926b63e6
commit 1faa832c5b

View File

@ -205,6 +205,7 @@ targ AS (
,factor AS (
SELECT
account
,segment
,targv
,targm
,targc
@ -217,10 +218,11 @@ FROM
targ t
LEFT OUTER JOIN rlarp.osm_pool o ON
o.billto_group = t.account
AND o.segm = 'Retail'
AND o.segm = t.segment
AND o.order_season = 2022
GROUP BY
account
,segment
,targv
,targm
,targc
@ -232,8 +234,8 @@ GROUP BY
rlarp.osm_log(doc)
SELECT
$${
"message":"adjust select retail customers to targets sales and margin",
"tag":"retail",
"message":"force accounts to match target total value and margin",
"tag":"retail plug",
"type":"build"
}$$::jsonb doc
RETURNING *
@ -298,8 +300,8 @@ GROUP BY
s.account = o.billto_group
CROSS JOIN log
WHERE
order_season = 2022
AND segm = 'Retail'
o.order_season = 2022
AND o.segm = s.segment
GROUP BY
o.fspr
,o.plnt ---master data