start working on pulling history by part group and data segment

This commit is contained in:
Paul Trowbridge 2025-08-05 20:14:52 -04:00
parent 533bbd1046
commit 7a73748b2a

View File

@ -3,32 +3,36 @@
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
DELETE FROM pricing.lastprice; DELETE FROM pricing.lastprice;
WITH
WITH srt AS ( --------SORT--------
SELECT srt AS (
customer, SELECT
mold, "Customer" customer,
part, "Part Group" partgroup,
version, i.v1ds dataseg,
qty, "Data Source" version,
ROUND(sales_usd / qty, 5) AS price, "Units" qty,
odate, ROUND(sales_usd / qty, 5) AS price,
oseas, odate,
ordnum, oseas,
quoten, ordnum,
ROW_NUMBER() OVER ( quoten,
PARTITION BY customer, mold, part, version ROW_NUMBER() OVER (
ORDER BY odate DESC PARTITION BY customer, mold, part, version
) AS rn ORDER BY odate DESC
FROM rlarp.osm_stack ) AS rn
WHERE FROM
--quotes can't be integrated until we have datasegment or correct part code rlarp.osm_stack_pretty o
version IN ('Actual'/*,'Quotes'*/) AND INNER JOIN CMSInterfaceIn.[CMS.CUSLG].ITEMM i ON
customer IS NOT NULL AND i.item = o.part
fs_line = '41010' AND WHERE
calc_status <> 'CANCELLED' AND --quotes can't be integrated until we have datasegment or correct part code
qty <> 0 AND version IN ('Actual'/*,'Quotes'*/) AND
mold <> '' customer IS NOT NULL AND
fs_line = '41010' AND
calc_status <> 'CANCELLED' AND
qty <> 0 AND
mold <> ''
), ),
json_rows AS ( json_rows AS (
SELECT SELECT