include plan and diff ase baseline iterations
This commit is contained in:
parent
f8bf1518f9
commit
28c14ece67
@ -6,10 +6,10 @@ target AS (select target_volume vincr, target_price pincr)
|
||||
,testv AS (
|
||||
SELECT
|
||||
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
|
||||
,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
|
||||
FROM
|
||||
rlarp.osm_pool
|
||||
@ -114,7 +114,7 @@ target AS (select target_volume vincr, target_price pincr)
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
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'
|
||||
END
|
||||
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
|
||||
@ -236,7 +236,7 @@ SELECT
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
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'
|
||||
END
|
||||
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
|
||||
|
@ -10,10 +10,10 @@ SELECT
|
||||
,doc->>'stamp' stamp
|
||||
,logid
|
||||
,tag
|
||||
,sum(value_usd) FILTER (WHERE iter = 'copy') sales
|
||||
,sum(cost_usd) FILTER (WHERE iter = 'copy') scogs
|
||||
,sum(value_usd) FILTER (WHERE iter <> 'copy') sales_adj
|
||||
,sum(cost_usd) FILTER (WHERE iter <> 'copy') scogs_adj
|
||||
,sum(value_usd) FILTER (WHERE iter IN ('plan','diff','copy')) sales
|
||||
,sum(cost_usd) FILTER (WHERE iter IN ('plan','diff','copy')) scogs
|
||||
,sum(value_usd) FILTER (WHERE iter <> NOT IN ('plan','diff','copy')) sales_adj
|
||||
,sum(cost_usd) FILTER (WHERE iter <> NOT IN ('plan','diff','copy')) scogs_adj
|
||||
FROM
|
||||
rlarp.osm_pool
|
||||
LEFT OUTER JOIN rlarp.osm_log ON
|
||||
|
@ -3,7 +3,7 @@ target AS (select incr_qty qincr)
|
||||
,testv AS (
|
||||
SELECT
|
||||
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
|
||||
FROM
|
||||
rlarp.osm_pool p
|
||||
@ -91,7 +91,7 @@ target AS (select incr_qty qincr)
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
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'
|
||||
END
|
||||
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
|
||||
|
@ -3,7 +3,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
,testv AS (
|
||||
SELECT
|
||||
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
|
||||
FROM
|
||||
rlarp.osm_pool
|
||||
@ -91,7 +91,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
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'
|
||||
END
|
||||
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
|
||||
|
@ -3,7 +3,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
,testv AS (
|
||||
SELECT
|
||||
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
|
||||
FROM
|
||||
rlarp.osm_pool
|
||||
@ -92,7 +92,7 @@ target AS (select target_vol vincr, target_prc pincr)
|
||||
-----------------additional params-------------------
|
||||
AND CASE (SELECT flag FROM flagv)
|
||||
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'
|
||||
END
|
||||
AND calc_status||flag <> 'CLOSEDREMAINDER' --exclude short ships when building order adjustments
|
||||
|
@ -95,12 +95,12 @@ GROUP BY
|
||||
order_month
|
||||
,seq
|
||||
,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 NOT IN ('copy','short ship','bad_ship')) "2022 adj 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','diff','pf')) "2022 adj 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 = 2022 AND iter IN ('copy','short ship','bad_ship')) "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 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','diff','pf')) "2022 adj value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2022) "2022 tot value_usd"
|
||||
FROM
|
||||
months
|
||||
|
Loading…
Reference in New Issue
Block a user