From 1faa832c5bdfa876c247fdd51ac12a049cbb3515 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Wed, 12 May 2021 11:46:02 -0400 Subject: [PATCH] use inbound segment to hook with exisiting baseline data --- offline/account_plug.sql | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/offline/account_plug.sql b/offline/account_plug.sql index 52ad207..d964266 100644 --- a/offline/account_plug.sql +++ b/offline/account_plug.sql @@ -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