include plan and diff ase baseline iterations

This commit is contained in:
Paul Trowbridge 2021-07-16 09:40:34 -04:00
parent f8bf1518f9
commit 28c14ece67
6 changed files with 19 additions and 19 deletions

View File

@ -6,10 +6,10 @@ target AS (select target_volume vincr, target_price pincr)
,testv AS ( ,testv AS (
SELECT SELECT
sum(units) tot sum(units) tot
,sum(units) FILTER (WHERE iter = 'copy') base ,sum(units) FILTER (WHERE iter IN ('copy','plan','diff')) base
,COALESCE(sum(units) FILTER (WHERE module = 'new basket'),0) newpart ,COALESCE(sum(units) FILTER (WHERE module = 'new basket'),0) newpart
,sum(value_loc *r_rate) totsales ,sum(value_loc *r_rate) totsales
,sum(value_loc *r_rate) FILTER (WHERE iter = 'copy') basesales ,sum(value_loc *r_rate) FILTER (WHERE iter IN ('plan','diff','copy')) basesales
,COALESCE(sum(value_loc *r_rate) FILTER (WHERE module = 'new basket'),0) newpartsales ,COALESCE(sum(value_loc *r_rate) FILTER (WHERE module = 'new basket'),0) newpartsales
FROM FROM
rlarp.osm_pool rlarp.osm_pool
@ -114,7 +114,7 @@ target AS (select target_volume vincr, target_price pincr)
-----------------additional params------------------- -----------------additional params-------------------
AND CASE (SELECT flag FROM flagv) AND CASE (SELECT flag FROM flagv)
WHEN 'scale all' THEN true WHEN 'scale all' THEN true
WHEN 'scale copy' THEN iter = 'copy' WHEN 'scale copy' THEN iter IN ('plan','diff','copy')
WHEN 'scale new part' THEN module = 'new basket' WHEN 'scale new part' THEN module = 'new basket'
END END
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
@ -236,7 +236,7 @@ SELECT
-----------------additional params------------------- -----------------additional params-------------------
AND CASE (SELECT flag FROM flagv) AND CASE (SELECT flag FROM flagv)
WHEN 'scale all' THEN true WHEN 'scale all' THEN true
WHEN 'scale copy' THEN iter = 'copy' WHEN 'scale copy' THEN iter IN ('plan','diff','copy')
WHEN 'scale new part' THEN module = 'new basket' WHEN 'scale new part' THEN module = 'new basket'
END END
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments

View File

@ -10,10 +10,10 @@ SELECT
,doc->>'stamp' stamp ,doc->>'stamp' stamp
,logid ,logid
,tag ,tag
,sum(value_usd) FILTER (WHERE iter = 'copy') sales ,sum(value_usd) FILTER (WHERE iter IN ('plan','diff','copy')) sales
,sum(cost_usd) FILTER (WHERE iter = 'copy') scogs ,sum(cost_usd) FILTER (WHERE iter IN ('plan','diff','copy')) scogs
,sum(value_usd) FILTER (WHERE iter <> 'copy') sales_adj ,sum(value_usd) FILTER (WHERE iter <> NOT IN ('plan','diff','copy')) sales_adj
,sum(cost_usd) FILTER (WHERE iter <> 'copy') scogs_adj ,sum(cost_usd) FILTER (WHERE iter <> NOT IN ('plan','diff','copy')) scogs_adj
FROM FROM
rlarp.osm_pool rlarp.osm_pool
LEFT OUTER JOIN rlarp.osm_log ON LEFT OUTER JOIN rlarp.osm_log ON

View File

@ -3,7 +3,7 @@ target AS (select incr_qty qincr)
,testv AS ( ,testv AS (
SELECT SELECT
sum(units) tot sum(units) tot
,sum(units) FILTER (WHERE iter = 'copy') base ,sum(units) FILTER (WHERE iter IN ('copy','plan','diff')) base
,sum(units) FILTER (WHERE module = 'new basket') newpart ,sum(units) FILTER (WHERE module = 'new basket') newpart
FROM FROM
rlarp.osm_pool p rlarp.osm_pool p
@ -91,13 +91,13 @@ target AS (select incr_qty qincr)
-----------------additional params------------------- -----------------additional params-------------------
AND CASE (SELECT flag FROM flagv) AND CASE (SELECT flag FROM flagv)
WHEN 'scale all' THEN true WHEN 'scale all' THEN true
WHEN 'scale copy' THEN iter = 'copy' WHEN 'scale copy' THEN iter IN ('copy','plan','diff')
WHEN 'scale new part' THEN module = 'new basket' WHEN 'scale new part' THEN module = 'new basket'
END END
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
AND order_date <= ship_date AND order_date <= ship_date
GROUP BY GROUP BY
fspr fspr
,plnt ---master data ,plnt ---master data
,promo --history date mix ,promo --history date mix
,terms ,terms

View File

@ -3,7 +3,7 @@ target AS (select target_vol vincr, target_prc pincr)
,testv AS ( ,testv AS (
SELECT SELECT
sum(units) tot sum(units) tot
,sum(units) FILTER (WHERE iter = 'copy') base ,sum(units) FILTER (WHERE iter IN ('plan','diff','copy')) base
,sum(units) FILTER (WHERE module = 'new basket') newpart ,sum(units) FILTER (WHERE module = 'new basket') newpart
FROM FROM
rlarp.osm_pool rlarp.osm_pool
@ -91,7 +91,7 @@ target AS (select target_vol vincr, target_prc pincr)
-----------------additional params------------------- -----------------additional params-------------------
AND CASE (SELECT flag FROM flagv) AND CASE (SELECT flag FROM flagv)
WHEN 'scale all' THEN true WHEN 'scale all' THEN true
WHEN 'scale copy' THEN iter = 'copy' WHEN 'scale copy' THEN iter IN ('plan','diff','copy')
WHEN 'scale new part' THEN module = 'new basket' WHEN 'scale new part' THEN module = 'new basket'
END END
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments

View File

@ -3,7 +3,7 @@ target AS (select target_vol vincr, target_prc pincr)
,testv AS ( ,testv AS (
SELECT SELECT
sum(units) tot sum(units) tot
,sum(units) FILTER (WHERE iter = 'copy') base ,sum(units) FILTER (WHERE iter IN ('plan','diff','copy')) base
,sum(units) FILTER (WHERE module = 'new basket') newpart ,sum(units) FILTER (WHERE module = 'new basket') newpart
FROM FROM
rlarp.osm_pool rlarp.osm_pool
@ -92,7 +92,7 @@ target AS (select target_vol vincr, target_prc pincr)
-----------------additional params------------------- -----------------additional params-------------------
AND CASE (SELECT flag FROM flagv) AND CASE (SELECT flag FROM flagv)
WHEN 'scale all' THEN true WHEN 'scale all' THEN true
WHEN 'scale copy' THEN iter = 'copy' WHEN 'scale copy' THEN iter IN ('plan','diff','copy')
WHEN 'scale new part' THEN module = 'new basket' WHEN 'scale new part' THEN module = 'new basket'
END END
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments

View File

@ -95,12 +95,12 @@ GROUP BY
order_month order_month
,seq ,seq
,SUM(units) FILTER (WHERE order_season = 2021) "2021 qty" ,SUM(units) FILTER (WHERE order_season = 2021) "2021 qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship')) "2022 base qty" ,SUM(units) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base qty"
,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship')) "2022 adj qty" ,SUM(units) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj qty"
,SUM(units) FILTER (WHERE order_season = 2022) "2022 tot qty" ,SUM(units) FILTER (WHERE order_season = 2022) "2022 tot qty"
,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 value_usd" ,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship')) "2022 base value_usd" ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter IN ('copy','short ship','bad_ship','plan')) "2022 base value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship')) "2022 adj value_usd" ,SUM(value_usd) FILTER (WHERE order_season = 2022 AND iter NOT IN ('copy','short ship','bad_ship','diff','pf')) "2022 adj value_usd"
,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd" ,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd"
FROM FROM
months months