vault backup: 2023-11-03 09:35:57

This commit is contained in:
Paul Trowbridge 2023-11-03 09:35:57 -04:00
parent a836d2ce24
commit 0be561a7f2
5 changed files with 4553 additions and 29 deletions

4494
out Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,37 +14,37 @@ partcodes AS (
_ds.colgrp = i.colgrp _ds.colgrp = i.colgrp
AND _ds.brand = i.branding AND _ds.brand = i.branding
WHERE WHERE
i.item ~ 'ULH12000' i.item ~ 'TUH1000'
AND part_group IS NOT NULL AND part_group IS NOT NULL
) )
,customers AS ( ,custs AS (
SELECT SELECT
dba dba
FROM FROM
rlarp.cust c rlarp.cust c
WHERE WHERE
c.dba ~ 'SUNSHINE GREENH' c.dba ~ 'DIAMOND '
) )
,allscenarios AS ( ,allscenarios AS (
SELECT DISTINCT SELECT DISTINCT
jsonb_build_object('baseitem',part_group,'customer',dba) sc jsonb_build_object('mold',part_group,'cust',dba) sc
FROM FROM
partcodes partcodes
CROSS JOIN customers CROSS JOIN custs
) )
,v1scenarios AS ( ,v1scenarios AS (
SELECT DISTINCT SELECT DISTINCT
jsonb_build_object('baseitem',part_group,'customer',dba,'v1dataseg',v1dataseg) sc jsonb_build_object('mold',part_group,'cust',dba,'v1dataseg',v1dataseg) sc
FROM FROM
partcodes partcodes
CROSS JOIN customers CROSS JOIN custs
) )
,v0scenarios AS ( ,v0scenarios AS (
SELECT DISTINCT SELECT DISTINCT
jsonb_build_object('baseitem',part_group,'customer',dba,'v0dataseg',v0dataseg) sc jsonb_build_object('mold',part_group,'cust',dba,'v0dataseg',v0dataseg) sc
FROM FROM
partcodes partcodes
CROSS JOIN customers CROSS JOIN custs
) )
,hist AS ( ,hist AS (
SELECT SELECT
@ -54,7 +54,7 @@ partcodes AS (
,p.season ,p.season
FROM FROM
allscenarios s allscenarios s
LEFT OUTER JOIN rlarp.price_pool_r1 p ON LEFT OUTER JOIN rlarp.price_pool_dev p ON
p.gset @> s.sc p.gset @> s.sc
) )
SELECT * FROM hist SELECT * FROM hist

View File

@ -1,18 +1,46 @@
WITH
--getj AS (
-- SELECT
-- jsonb_build_object('mold',stlc) doc
-- FROM
-- "CMS.CUSLG".itemm
-- WHERE
-- item = $1
--)
agg AS (
SELECT
gset
,agglevel
,season
FROM
rlarp.price_pool_dev
WHERE
--gset @> '{"mold":"XNS0T1G3"}'::jsonb
gset @> jsonb_build_object(
'mold','TUH10000',
'vers','A'
)
AND (
gset->>'cust' ~ 'DIAMOND'
OR NOT gset ? 'cust'
)
ORDER BY
agglevel ASC
)
SELECT SELECT
gset jsonb_build_object('agg',agglevel )
,agglevel || jsonb_build_object(
,e.k 'data',
,e.v->>'units' units jsonb_agg(gset || jsonb_build_object('season',season))
,e.v->>'price_usd' price_usd ) data
,e.v->>'target_price' target_price
FROM FROM
rlarp.price_pool_dev agg
LEFT JOIN LATERAL JSONB_EACH(season) e(k,v) ON TRUE GROUP BY
WHERE agglevel
--gset @> '{"mold":"XNS0T1G3"}'::jsonb LIMIT 10
gset @> jsonb_build_object( --SELECT
'mold','TUH10000', -- jsonb_pretty(agglevel) agglevel
'vers','A' -- ,jsonb_pretty(gset) gset
) -- ,jsonb_pretty(season) season
ORDER BY --FROM
agglevel ASC; -- agg

View File

@ -1,4 +1,4 @@
------------real history on target scenario------------ -----------real history on target scenario------------
WITH WITH
partcodes AS ( partcodes AS (
SELECT SELECT

View File

@ -126,3 +126,5 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
GROUP BY GROUP BY
gset gset
) WITH DATA; ) WITH DATA;
create index ppd_gset on rlarp.price_pool_dev using gin (gset);