isolate price change on no volume adjustment
This commit is contained in:
parent
0e904c1631
commit
d5c2980bb1
@ -208,15 +208,30 @@ WHERE
|
|||||||
SELECT * FROM baseline WHERE (SELECT COUNT(*) FROM volume_only) = 0
|
SELECT * FROM baseline WHERE (SELECT COUNT(*) FROM volume_only) = 0
|
||||||
)
|
)
|
||||||
,pscale AS (
|
,pscale AS (
|
||||||
----what if the selection has several value columns, which one to use?-----
|
SELECT
|
||||||
SELECT
|
(SELECT pincr FROM target) AS target_increment
|
||||||
(SELECT pincr FROM target) AS target_increment
|
,sum($$||format('%I',_value_col)||') AS value'||$$
|
||||||
,sum("Amount") AS value
|
,CASE WHEN (SELECT sum($$||format('%I',_value_col)||$$) FROM volume) = 0 THEN
|
||||||
,CASE WHEN (SELECT vscale.
|
--if the base value is -0- scaling will not work, need to generate price, factor goes to -0-
|
||||||
((SELECT pincr FROM target)-(SELECT sum("Amount") FROM volume))/(SELECT sum("Amount") FROM volume)
|
0
|
||||||
,CASE WHEN (SELECT sum("Amount") FROM volume) = 0 THEN 0 ELSE (SELECT pincr FROM target)/sum("Amount") FROM volume END factor
|
ELSE
|
||||||
FROM
|
--expects inbound partial adjustment from volume table
|
||||||
volume
|
--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 (
|
,pricing AS (
|
||||||
SELECT
|
SELECT
|
||||||
@ -232,7 +247,7 @@ INSERT INTO
|
|||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
volume
|
volume_only
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user