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