put the column names back
This commit is contained in:
parent
061387c1dc
commit
d557fe9cc3
@ -50,13 +50,13 @@ SELECT
|
||||
,plnt
|
||||
,promo
|
||||
,terms
|
||||
,bill_cust||' - '||bc.bvname bill_custd
|
||||
,ship_cust||' - '||sc.bvname ship_custd
|
||||
,bill_cust||' - '||bc.bvname bill_cust_descr
|
||||
,ship_cust||' - '||sc.bvname ship_cust_descr
|
||||
,dsm
|
||||
,coalesce(repc.repp,dsm) dsmd
|
||||
,coalesce(repc.repp,dsm) quota_rep_descr
|
||||
,repc.director
|
||||
,account bill_dba
|
||||
,shipgrp ship_dba
|
||||
,account billto_group
|
||||
,shipgrp shipto_group
|
||||
,chan
|
||||
,chansub
|
||||
,CASE seg.segm
|
||||
@ -69,35 +69,35 @@ SELECT
|
||||
ELSE o.chan
|
||||
END chan_retail
|
||||
,part
|
||||
,part||coalesce(' - '||i.descr,'') partd
|
||||
,stlcd partgroup
|
||||
,brnd
|
||||
,o.majg||' - '||i.majgd majgd
|
||||
,o.ming||' - '||i.mingd mingd
|
||||
,o.majs||' - '||i.majsd majsd
|
||||
,o.mins||' - '||i.minsd minsd
|
||||
,part||coalesce(' - '||i.descr,'') part_descr
|
||||
,stlcd part_group
|
||||
,brnd branding
|
||||
,o.majg||' - '||i.majgd majg_descr
|
||||
,o.ming||' - '||i.mingd ming_descr
|
||||
,o.majs||' - '||i.majsd majs_descr
|
||||
,o.mins||' - '||i.minsd mins_descr
|
||||
,seg.segm
|
||||
,fs_line
|
||||
,r_currency
|
||||
,r_rate
|
||||
,c_currency
|
||||
,c_rate
|
||||
,fb_qty
|
||||
,fb_val_loc
|
||||
,fb_qty units
|
||||
,fb_val_loc value_loc
|
||||
,fb_val_loc * r_rate value_usd
|
||||
,fb_cst_loc
|
||||
,fb_cst_loc cost_loc
|
||||
,fb_cst_loc * c_rate cost_usd
|
||||
,calc_status
|
||||
,flag
|
||||
,o.odate
|
||||
,to_char(CASE WHEN extract(month FROM o.odate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.odate),'FM00')||' - '||to_char(o.odate,'TMMon') omonth
|
||||
,oseas
|
||||
,rdate
|
||||
,to_char(CASE WHEN extract(month FROM o.rdate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.rdate),'FM00')||' - '||to_char(o.rdate,'TMMon') rmonth
|
||||
,rseas
|
||||
,sdate
|
||||
,to_char(CASE WHEN extract(month FROM o.sdate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon') smonth
|
||||
,sseas
|
||||
,o.odate order_date
|
||||
,to_char(CASE WHEN extract(month FROM o.odate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.odate),'FM00')||' - '||to_char(o.odate,'TMMon') order_month
|
||||
,oseas order_season
|
||||
,rdate request_date
|
||||
,to_char(CASE WHEN extract(month FROM o.rdate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.rdate),'FM00')||' - '||to_char(o.rdate,'TMMon') request_month
|
||||
,rseas request_season
|
||||
,sdate ship_date
|
||||
,to_char(CASE WHEN extract(month FROM o.sdate) > 6 THEN -5 ELSE 7 END + extract(month FROM o.sdate),'FM00')||' - '||to_char(o.sdate,'TMMon') ship_month
|
||||
,sseas ship_season
|
||||
,version
|
||||
,iter
|
||||
,null::int logid
|
||||
|
@ -6,20 +6,20 @@ SELECT
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director_descr
|
||||
,director
|
||||
,segm
|
||||
,mod_chan
|
||||
,mod_chansub
|
||||
,chan
|
||||
,chansub
|
||||
---------product info------------------
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
,brand
|
||||
,part_family
|
||||
--,brand
|
||||
--,part_family
|
||||
,part_group
|
||||
,branding
|
||||
,color
|
||||
--,color
|
||||
,part_descr
|
||||
---------dates-------------------------
|
||||
,order_season
|
||||
@ -38,7 +38,7 @@ SELECT
|
||||
,sum(cost_usd) cost_usd
|
||||
,sum(units) units
|
||||
FROM
|
||||
rlarp.osm_fcpool
|
||||
rlarp.osm_pool
|
||||
WHERE
|
||||
quota_rep_descr = 'rep_replace'
|
||||
GROUP BY
|
||||
@ -48,20 +48,20 @@ GROUP BY
|
||||
,ship_cust_descr
|
||||
,shipto_group
|
||||
,quota_rep_descr
|
||||
,director_descr
|
||||
,director
|
||||
,segm
|
||||
,mod_chan
|
||||
,mod_chansub
|
||||
,chan
|
||||
,chansub
|
||||
---------product info------------------
|
||||
,majg_descr
|
||||
,ming_descr
|
||||
,majs_descr
|
||||
,mins_descr
|
||||
,brand
|
||||
,part_family
|
||||
--,brand
|
||||
--,part_family
|
||||
,part_group
|
||||
,branding
|
||||
,color
|
||||
--,color
|
||||
,part_descr
|
||||
---------dates-------------------------
|
||||
,order_season
|
||||
|
@ -5,18 +5,18 @@ mseq AS (
|
||||
SELECT * FROM
|
||||
(
|
||||
VALUES
|
||||
('Jun',1)
|
||||
,('Jul',2)
|
||||
,('Aug',3)
|
||||
,('Sep',4)
|
||||
,('Oct',5)
|
||||
,('Nov',6)
|
||||
,('Dec',7)
|
||||
,('Jan',8)
|
||||
,('Feb',9)
|
||||
,('Mar',10)
|
||||
,('Apr',11)
|
||||
,('May',12)
|
||||
('01 - Jun',1)
|
||||
,('02 - Jul',2)
|
||||
,('03 - Aug',3)
|
||||
,('04 - Sep',4)
|
||||
,('05 - Oct',5)
|
||||
,('06 - Nov',6)
|
||||
,('07 - Dec',7)
|
||||
,('08 - Jan',8)
|
||||
,('09 - Feb',9)
|
||||
,('10 - Mar',10)
|
||||
,('11 - Apr',11)
|
||||
,('12 - May',12)
|
||||
|
||||
) x(m,s)
|
||||
)
|
||||
@ -33,10 +33,10 @@ SELECT
|
||||
,SUM(units) units
|
||||
,SUM(value_usd) value_usd
|
||||
FROM
|
||||
rlarp.osm_fcpool
|
||||
rlarp.osm_pool
|
||||
WHERE
|
||||
where_clause
|
||||
AND order_season IN (2019,2020)
|
||||
AND order_season IN (2020,2021)
|
||||
GROUP BY
|
||||
order_season
|
||||
,order_month
|
||||
@ -94,14 +94,14 @@ GROUP BY
|
||||
SELECT
|
||||
order_month
|
||||
,seq
|
||||
,SUM(units) FILTER (WHERE order_season = 2019) "2019 qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2020 AND iter IN ('copy','short ship','bad_ship')) "2020 base qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2020 AND iter NOT IN ('copy','short ship','bad_ship')) "2020 adj qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2020) "2020 tot qty"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2019) "2019 value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2020 AND iter IN ('copy','short ship','bad_ship')) "2020 base value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2020 AND iter NOT IN ('copy','short ship','bad_ship')) "2020 adj value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2020) "2020 tot value_usd"
|
||||
,SUM(units) FILTER (WHERE order_season = 2020) "2020 qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021 AND iter IN ('copy','short ship','bad_ship')) "2021 base qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021 AND iter NOT IN ('copy','short ship','bad_ship')) "2021 adj qty"
|
||||
,SUM(units) FILTER (WHERE order_season = 2021) "2021 tot qty"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2020) "2020 value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter IN ('copy','short ship','bad_ship')) "2021 base value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021 AND iter NOT IN ('copy','short ship','bad_ship')) "2021 adj value_usd"
|
||||
,SUM(value_usd) FILTER (WHERE order_season = 2021) "2021 tot value_usd"
|
||||
FROM
|
||||
months
|
||||
GROUP BY
|
||||
@ -113,14 +113,14 @@ GROUP BY
|
||||
,mlist AS (
|
||||
SELECT
|
||||
mseq.m order_month
|
||||
,"2019 qty"
|
||||
,"2020 base qty"
|
||||
,"2020 adj qty"
|
||||
,"2020 tot qty"
|
||||
,"2019 value_usd"
|
||||
,"2020 base value_usd"
|
||||
,"2020 adj value_usd"
|
||||
,"2020 tot value_usd"
|
||||
,"2020 qty"
|
||||
,"2021 base qty"
|
||||
,"2021 adj qty"
|
||||
,"2021 tot qty"
|
||||
,"2020 value_usd"
|
||||
,"2021 base value_usd"
|
||||
,"2021 adj value_usd"
|
||||
,"2021 tot value_usd"
|
||||
FROM
|
||||
mseq
|
||||
LEFT OUTER JOIN mpvt ON
|
||||
|
Loading…
Reference in New Issue
Block a user