snap current cost

This commit is contained in:
Paul Trowbridge 2020-02-21 11:16:05 -05:00
parent ab72f94775
commit 8bed8cd399

View File

@ -0,0 +1,38 @@
BEGIN;
WITH
plist AS (
SELECT DISTINCT
part
,plnt
FROM
rlarp.osmf_dev
)
,clist AS (
SELECT
p.part
,p.plnt
,COALESCE(im.cgstcs,ip.chstcs, ir.y0stcs) stdcost
FROM
plist p
LEFT OUTER JOIN lgdat.icstm im ON
im.cgpart = p.part
AND im.cgplnt = p.plnt
LEFT OUTER JOIN lgdat.icstp ip ON
ip.chpart = p.part
AND ip.chplnt = p.plnt
LEFT OUTER JOIN lgdat.icstr ir ON
ir.y0part = p.part
AND ir.y0plnt = p.plnt
)
UPDATE
rlarp.osmf_dev o
SET
fb_cst_loc_cur = c.stdcost * o.fb_qty
FROM
clist c
WHERE
c.part = o.part
AND c.plnt = o.plnt;
commit;