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
AND _ds.brand = i.branding
WHERE
i.item ~ 'ULH12000'
i.item ~ 'TUH1000'
AND part_group IS NOT NULL
)
,customers AS (
,custs AS (
SELECT
dba
FROM
rlarp.cust c
WHERE
c.dba ~ 'SUNSHINE GREENH'
c.dba ~ 'DIAMOND '
)
,allscenarios AS (
SELECT DISTINCT
jsonb_build_object('baseitem',part_group,'customer',dba) sc
jsonb_build_object('mold',part_group,'cust',dba) sc
FROM
partcodes
CROSS JOIN customers
CROSS JOIN custs
)
,v1scenarios AS (
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
partcodes
CROSS JOIN customers
CROSS JOIN custs
)
,v0scenarios AS (
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
partcodes
CROSS JOIN customers
CROSS JOIN custs
)
,hist AS (
SELECT
@ -54,7 +54,7 @@ partcodes AS (
,p.season
FROM
allscenarios s
LEFT OUTER JOIN rlarp.price_pool_r1 p ON
LEFT OUTER JOIN rlarp.price_pool_dev p ON
p.gset @> s.sc
)
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
gset
,agglevel
,e.k
,e.v->>'units' units
,e.v->>'price_usd' price_usd
,e.v->>'target_price' target_price
jsonb_build_object('agg',agglevel )
|| jsonb_build_object(
'data',
jsonb_agg(gset || jsonb_build_object('season',season))
) data
FROM
rlarp.price_pool_dev
LEFT JOIN LATERAL JSONB_EACH(season) e(k,v) ON TRUE
WHERE
--gset @> '{"mold":"XNS0T1G3"}'::jsonb
gset @> jsonb_build_object(
'mold','TUH10000',
'vers','A'
)
ORDER BY
agglevel ASC;
agg
GROUP BY
agglevel
LIMIT 10
--SELECT
-- jsonb_pretty(agglevel) agglevel
-- ,jsonb_pretty(gset) gset
-- ,jsonb_pretty(season) season
--FROM
-- agg

View File

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

View File

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