point to itemm

This commit is contained in:
Paul Trowbridge 2024-02-29 13:07:03 -05:00
parent 5234516dee
commit de9ecd5033
2 changed files with 21 additions and 18 deletions

View File

@ -42,7 +42,7 @@ BEGIN
INTO
_mold,_stlc,_v1ds , _v0ds, _iidx
FROM
"CMS.CUSLG".itemmv i
"CMS.CUSLG".itemm i
INNER JOIN rlarp.molds m ON
m.stlc = i.stlc
WHERE

View File

@ -67,8 +67,8 @@ BEGIN
,idxk
,prefer
,pltq
,fstd_usd
,fstd_usd_ina
,futstdus
,futstdus_ina
INTO
_mold
,_item
@ -80,30 +80,33 @@ BEGIN
FROM
(
SELECT
m.part_group
i.partgroup part_group
,min(i.item) item
,i.stlc
,i.v1ds
,i.v0ds
,i.pltq
,avg(i.fstd_usd) FILTER (WHERE aplnt <> 'I') fstd_usd
,avg(i.fstd_usd) fstd_usd_ina
,_ds.dataseg v0ds
,i.mpck pltq
,avg(i.futstdus) FILTER (WHERE aplnt <> 'I') futstdus
,avg(i.futstdus) futstdus_ina
,jsonb_strip_nulls(jsonb_build_object('assc',CASE WHEN i.assc <> '' THEN i.assc ELSE null::text END,'majg',i.majg::int,'coltier',i.coltier)) idxk
,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN i.v0ds = _v0ds THEN 1 ELSE 0 END END prefer
,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN _ds.dataseg = _v0ds THEN 1 ELSE 0 END END prefer
FROM
"CMS.CUSLG".itemmv i
INNER JOIN rlarp.molds m ON
m.stlc = i.stlc
"CMS.CUSLG".itemm i
LEFT OUTER JOIN _ds ON
_ds.colgrp = i.colgrp
AND _ds.brand = SUBSTRING(i.branding,1,1)
--INNER JOIN rlarp.molds m ON
-- m.stlc = i.stlc
WHERE
i.stlc = _stlc
GROUP BY
m.part_group
i.partgroup
,i.stlc
,i.v1ds
,i.v0ds
,i.pltq
,_ds.dataseg
,i.mpck
,jsonb_strip_nulls(jsonb_build_object('assc',CASE WHEN i.assc <> '' THEN i.assc ELSE null::text END,'majg',i.majg::int,'coltier',i.coltier))
,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN i.v0ds = _v0ds THEN 1 ELSE 0 END END
,CASE WHEN i.v1ds = _v1ds THEN 2 ELSE CASE WHEN _ds.dataseg = _v0ds THEN 1 ELSE 0 END END
) best
ORDER BY
prefer DESC
@ -117,8 +120,8 @@ BEGIN
,'itemrel',_itemr
,'iidx',_iidx
,'pltq',_pltq
,'fstd_usd',_fstd
,'fstd_usd_ina',_fstdina
,'futstdus',_fstd
,'futstdus_ina',_fstdina
)
);
--RAISE NOTICE 'item data %', jsonb_pretty(_product||_input);