isolate price change on no volume adjustment
This commit is contained in:
parent
0e904c1631
commit
d5c2980bb1
@ -208,14 +208,29 @@ WHERE
|
||||
SELECT * FROM baseline WHERE (SELECT COUNT(*) FROM volume_only) = 0
|
||||
)
|
||||
,pscale AS (
|
||||
----what if the selection has several value columns, which one to use?-----
|
||||
SELECT
|
||||
SELECT
|
||||
(SELECT pincr FROM target) AS target_increment
|
||||
,sum("Amount") AS value
|
||||
,CASE WHEN (SELECT vscale.
|
||||
((SELECT pincr FROM target)-(SELECT sum("Amount") FROM volume))/(SELECT sum("Amount") FROM volume)
|
||||
,CASE WHEN (SELECT sum("Amount") FROM volume) = 0 THEN 0 ELSE (SELECT pincr FROM target)/sum("Amount") FROM volume END factor
|
||||
FROM
|
||||
,sum($$||format('%I',_value_col)||') AS value'||$$
|
||||
,CASE WHEN (SELECT sum($$||format('%I',_value_col)||$$) FROM volume) = 0 THEN
|
||||
--if the base value is -0- scaling will not work, need to generate price, factor goes to -0-
|
||||
0
|
||||
ELSE
|
||||
--expects inbound partial adjustment from volume table
|
||||
--if the volume table does not have enough price added, need to get to goal increment
|
||||
--multiplying by the raw factor without adding 1 will work since this data set will be added to the volume data set
|
||||
((SELECT pincr FROM target)-(SELECT sum($$||format('%I',_value_col)||$$) FROM volume))/(SELECT sum($$||format('%I',_value_col)||$$) FROM volume)
|
||||
END factor
|
||||
,CASE WHEN (SELECT sum($$||format('%I',_value_col)||$$) FROM volume) = 0 THEN
|
||||
CASE WHEN ((SELECT pincr::numeric FROM target) - (SELECT sum($$||format('%I',_value_col)||$$) FROM volume)) <> 0 THEN
|
||||
--if the base value is -0- but the target value hasn't been achieved, derive a price to apply
|
||||
((SELECT pincr::numeric FROM target) - (SELECT sum($$||format('%I',_value_col)||$$) FROM volume))/(SELECT sum($$||format('%I',_units_col)||$$) FROM volume)
|
||||
ELSE
|
||||
0
|
||||
END
|
||||
ELSE
|
||||
0
|
||||
END mod_price
|
||||
FROM
|
||||
volume
|
||||
)
|
||||
,pricing AS (
|
||||
@ -232,7 +247,7 @@ INSERT INTO
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
volume
|
||||
volume_only
|
||||
UNION ALL
|
||||
SELECT
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user