swap out basemix columns

This commit is contained in:
Trowbridge 2020-02-13 12:19:45 -05:00
parent 04276a89cb
commit 610c78f36f

View File

@ -38,112 +38,50 @@ target AS (select target_vol vincr, target_prc pincr)
) )
,basemix AS ( ,basemix AS (
SELECT SELECT
plnt ---master data fspr
,0::numeric(11,0) "ddord#" --0 ,plnt ---master data
,0::numeric(11,0) "dditm#" --0
,0::numeric(11,0) "fgbol#" --0
,0::numeric(11,0) "fgent#" --0
,0::numeric(9,0) "diinv#" --0
,0::numeric(3,0) "dilin#" --0
,promo --history date mix ,promo --history date mix
,null::text return_reas --0
,terms ,terms
,''::text custpo --0 ,bill_cust_descr --history cust mix
,'I' dhincr --0 ,ship_cust_descr --history cust mix
,null::numeric diext ,dsm
,null::numeric ditdis ,quota_rep_descr --master data
,null::date dcodat --calculated date mix ,director
,null::date ddqdat --calculated date mix ,billto_group --master data
,null::date dcmdat --calculated date mix ,shipto_group
,null::date dhidat --calculated date mix
,null::text fspr --calculated date mix
,remit_to --master data
,bill_class --master data
,bill_cust --history cust mix
,bill_rep --master data
,bill_terr --master data
,ship_class --master data
,ship_cust --history cust mix
,ship_rep --master data
,ship_terr --master data
,quota_rep --master data
,account --master data
,shipgrp --master data
,geo --master data
,chan --master data ,chan --master data
,orig_ctry --master data ,chansub
,orig_prov --master data ,chan_retail
,orig_post --master data ,part
,dest_ctry --master data ,part_descr
,dest_prov --master data ,part_group
,dest_post --master data ,branding
,part --history part mix ,majg_descr
,ord_gldc --master data ,ming_descr
,majg --master data ,majs_descr
,ming --master data ,mins_descr
,majs --master data ,segm
,mins --master data
,gldc --master data
,glec --master data
,harm --master data
,clss --master data
,brand --master data
,assc --master data
,fs_line --master data ,fs_line --master data
,r_currency --history cust mix ,r_currency --history cust mix
,r_rate --master data ,r_rate --master data
,c_currency --master data ,c_currency --master data
,c_rate --master data ,c_rate --master data
,0::numeric(15,5) ddqtoi --0 ,sum(coalesce(units,0)) units --history value
,0::numeric(15,5) ddqtsi --0 ,sum(coalesce(value_loc,0)) value_loc --history value
,0::numeric(15,5) fgqshp --0 ,sum(coalesce(value_usd,0)) value_usd --0
,0::numeric(15,5) diqtsh --0 ,sum(coalesce(cost_loc,0)) cost_loc --history part mix
,sum(coalesce(fb_qty,0)) fb_qty --history value ,sum(coalesce(cost_usd,0)) cost_usd
,sum(coalesce(fb_cst_loc,0)) fb_cst_loc --history part mix
,sum(coalesce(fb_cst_loc_cur,0)) fb_cst_loc_cur --master data
,sum(coalesce(fb_cst_loc_fut,0)) fb_cst_loc_fut --master data
,sum(coalesce(fb_val_loc,0)) fb_val_loc --history value
,sum(coalesce(fb_val_loc_pl,0)) fb_val_loc_pl --0
,calc_status --0 ,calc_status --0
,flag --0 ,flag --0
,orderdate --history date mix ,order_date --history date mix
,requestdate --history date mix
,shipdate --history date mix
,adj_orderdate --history
,adj_requestdate --history
,adj_shipdate --history
,null::text "version" --calculated
,null::text iter --calculated
---------------ui columns-------------------------
,order_season
,order_month ,order_month
,ship_season ,order_season
,ship_month ,request_date --history date mix
,request_season
,request_month ,request_month
,part_descr ,request_season
,part_family ,ship_date --history date mix
,part_group ,ship_month
,branding ,ship_season
,color
,segm
,bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,majg_descr
,ming_descr
,majs_descr
,mins_descr
,mod_chan
,mod_chansub
,quota_rep_descr
,director_descr
,null value_loc
,null value_usd
,null cost_loc
,null cost_usd
,null units
FROM FROM
rlarp.osm_pool rlarp.osm_pool
WHERE WHERE
@ -156,43 +94,31 @@ target AS (select target_vol vincr, target_prc pincr)
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 adj_orderdate <= adj_shipdate AND order_date <= ship_date
GROUP BY GROUP BY
plnt ---master data fspr
,promo ,plnt ---master data
,promo --history date mix
,terms ,terms
,remit_to --master data ,bill_cust_descr --history cust mix
,bill_class --master data ,ship_cust_descr --history cust mix
,bill_cust --history cust mix ,dsm
,bill_rep --master data ,quota_rep_descr --master data
,bill_terr --master data ,director
,ship_class --master data ,billto_group --master data
,ship_cust --history cust mix ,shipto_group
,ship_rep --master data
,ship_terr --master data
,quota_rep --master data
,account --master data
,shipgrp --master data
,geo --master data
,chan --master data ,chan --master data
,orig_ctry --master data ,chansub
,orig_prov --master data ,chan_retail
,orig_post --master data ,part
,dest_ctry --master data ,part_descr
,dest_prov --master data ,part_group
,dest_post --master data ,branding
,part --history part mix ,majg_descr
,ord_gldc --master data ,ming_descr
,majg --master data ,majs_descr
,ming --master data ,mins_descr
,majs --master data ,segm
,mins --master data
,gldc --master data
,glec --master data
,harm --master data
,clss --master data
,brand --master data
,assc --master data
,fs_line --master data ,fs_line --master data
,r_currency --history cust mix ,r_currency --history cust mix
,r_rate --master data ,r_rate --master data
@ -200,37 +126,15 @@ target AS (select target_vol vincr, target_prc pincr)
,c_rate --master data ,c_rate --master data
,calc_status --0 ,calc_status --0
,flag --0 ,flag --0
,orderdate --history date mix ,order_date --history date mix
,requestdate --history date mix
,shipdate --history date mix
,adj_orderdate --history
,adj_requestdate --history
,adj_shipdate --history
---------------ui columns-------------------------
,order_season
,order_month ,order_month
,ship_season ,order_season
,ship_month ,request_date --history date mix
,request_season
,request_month ,request_month
,part_descr ,request_season
,part_family ,ship_date --history date mix
,part_group ,ship_month
,branding ,ship_season
,color
,segm
,bill_cust_descr
,billto_group
,ship_cust_descr
,shipto_group
,majg_descr
,ming_descr
,majs_descr
,mins_descr
,mod_chan
,mod_chansub
,quota_rep_descr
,director_descr
) )
,vscale AS ( ,vscale AS (
SELECT SELECT