vault backup: 2023-11-03 09:35:57
This commit is contained in:
parent
a836d2ce24
commit
0be561a7f2
20
sql/dev.sql
20
sql/dev.sql
@ -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
|
||||||
|
64
sql/get.sql
64
sql/get.sql
@ -1,18 +1,46 @@
|
|||||||
SELECT
|
WITH
|
||||||
gset
|
--getj AS (
|
||||||
,agglevel
|
-- SELECT
|
||||||
,e.k
|
-- jsonb_build_object('mold',stlc) doc
|
||||||
,e.v->>'units' units
|
-- FROM
|
||||||
,e.v->>'price_usd' price_usd
|
-- "CMS.CUSLG".itemm
|
||||||
,e.v->>'target_price' target_price
|
-- WHERE
|
||||||
FROM
|
-- item = $1
|
||||||
rlarp.price_pool_dev
|
--)
|
||||||
LEFT JOIN LATERAL JSONB_EACH(season) e(k,v) ON TRUE
|
agg AS (
|
||||||
WHERE
|
SELECT
|
||||||
--gset @> '{"mold":"XNS0T1G3"}'::jsonb
|
gset
|
||||||
gset @> jsonb_build_object(
|
,agglevel
|
||||||
'mold','TUH10000',
|
,season
|
||||||
'vers','A'
|
FROM
|
||||||
)
|
rlarp.price_pool_dev
|
||||||
ORDER BY
|
WHERE
|
||||||
agglevel ASC;
|
--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
|
||||||
|
jsonb_build_object('agg',agglevel )
|
||||||
|
|| jsonb_build_object(
|
||||||
|
'data',
|
||||||
|
jsonb_agg(gset || jsonb_build_object('season',season))
|
||||||
|
) data
|
||||||
|
FROM
|
||||||
|
agg
|
||||||
|
GROUP BY
|
||||||
|
agglevel
|
||||||
|
LIMIT 10
|
||||||
|
--SELECT
|
||||||
|
-- jsonb_pretty(agglevel) agglevel
|
||||||
|
-- ,jsonb_pretty(gset) gset
|
||||||
|
-- ,jsonb_pretty(season) season
|
||||||
|
--FROM
|
||||||
|
-- agg
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
------------real history on target scenario------------
|
-----------real history on target scenario------------
|
||||||
WITH
|
WITH
|
||||||
partcodes AS (
|
partcodes AS (
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user