make sure days are between 1 and 28

This commit is contained in:
Paul Trowbridge 2019-04-16 13:26:39 +00:00
parent 06c545dbc6
commit 7008f57f66
3 changed files with 4 additions and 4 deletions

View File

@ -174,7 +174,7 @@ target AS (select target_increment incr)
_month
,seq
,promo
,round((dom_wa/value_usd)::numeric,0)::int odom
,greatest(least(round((dom_wa/value_usd)::numeric,0)::int,28),1) odom
,round((rlag_wa/value_usd)::numeric,0)::int rlag
,round((slag_wa/value_usd)::numeric,0)::int slag
,value_usd/sum(value_usd) over (partition by _month) momix
@ -575,4 +575,4 @@ GROUP BY
,version
,iter
)
SELECT json_agg(row_to_json(insagg)) x from insagg
SELECT json_agg(row_to_json(insagg)) x from insagg

View File

@ -169,7 +169,7 @@ target AS (select target_volume vincr, target_price pincr)
_month
,seq
,promo
,round((dom_wa/value_usd)::numeric,0)::int odom
,greatest(least(round((dom_wa/value_usd)::numeric,0)::int,28),1) odom
,round((rlag_wa/value_usd)::numeric,0)::int rlag
,round((slag_wa/value_usd)::numeric,0)::int slag
,value_usd/sum(value_usd) over (partition by _month) momix

View File

@ -247,7 +247,7 @@ target AS (select $$replace_request$$::json def)
_month
,seq
,promo
,round((dom_wa/value_usd)::numeric,0)::int odom
,greatest(least(round((dom_wa/value_usd)::numeric,0)::int,28),1) odom
,round((rlag_wa/value_usd)::numeric,0)::int rlag
,round((slag_wa/value_usd)::numeric,0)::int slag
,value_usd/sum(value_usd) over (partition by _month) momix