commit: 2025-03-31 15:12:57
This commit is contained in:
parent
89223b09dd
commit
a5546ecea7
@ -119,6 +119,7 @@ pgrp AS (
|
||||
,sg.sortmo
|
||||
-- ,o.calc_status
|
||||
)
|
||||
,guid AS (
|
||||
SELECT
|
||||
grp.account
|
||||
,grp.shipgrp
|
||||
@ -139,10 +140,11 @@ pgrp AS (
|
||||
,grp.lbs
|
||||
,grp.qty
|
||||
,grp.sales_usd
|
||||
,CASE WHEN round(grp.sales_usd/grp.qty,5) = 0 THEN null ELSE round(grp.sales_usd/grp.qty,5) END hist_price
|
||||
,grp.cost_curstd_usd
|
||||
,sum(grp.lbs) OVER (PARTITION BY shipgrp, oseas, dsm) shiplbs
|
||||
,seq.floor
|
||||
,seq.ceiling
|
||||
,CASE WHEN seq.floor = 0 THEN null else seq.floor END floor
|
||||
,CASE WHEN seq.ceiling = 0 THEN null else seq.ceiling END ceiling
|
||||
,seq.uselimits
|
||||
,seq.price
|
||||
,seq.avgprice
|
||||
@ -192,3 +194,37 @@ pgrp AS (
|
||||
AND seq.rn = 1
|
||||
LEFT OUTER JOIN rlarp.repc r ON
|
||||
r.repp = grp.dsm
|
||||
)
|
||||
SELECT
|
||||
account
|
||||
,shipgrp
|
||||
,chan
|
||||
,dsm
|
||||
,director
|
||||
,lu
|
||||
--,partgroup
|
||||
--,pricegroup
|
||||
,part
|
||||
-- ,glec
|
||||
,oseas
|
||||
,omon
|
||||
-- ,odate
|
||||
,sseas
|
||||
,smon
|
||||
-- ,sdate
|
||||
,lbs
|
||||
,qty
|
||||
,sales_usd
|
||||
,hist_price
|
||||
,cost_curstd_usd
|
||||
,shiplbs
|
||||
,floor
|
||||
,ceiling
|
||||
,uselimits
|
||||
,price
|
||||
,avgprice
|
||||
,pltq
|
||||
,guid
|
||||
,least(hist_price, price, avgprice) lowest_last
|
||||
FROM
|
||||
guid
|
||||
|
||||
Loading…
Reference in New Issue
Block a user