vault backup: 2023-10-18 07:49:23
This commit is contained in:
parent
a6bfd7c8e0
commit
ea4d8213d4
@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
|
||||
o.customer
|
||||
,o.chanwide
|
||||
,o.nursery_region
|
||||
,o.general_region
|
||||
,c.greenhouse_region
|
||||
,m.part_group baseitem
|
||||
,m.majg
|
||||
,m.assc
|
||||
@ -46,6 +46,8 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
|
||||
AND tq.mold = i.stlc
|
||||
AND tq.chan = 'DISTRIB DROP SHIP'
|
||||
AND tq.data_segment = _ds.dataseg
|
||||
LEFT OUTER JOIN rlarp.cust c ON
|
||||
c.code = CASE o.chan WHEN 'DIR' THEN o.bill_cust ELSE o.ship_cust END
|
||||
WHERE
|
||||
o.version <> '6/1 Order Book'
|
||||
--AND o.part like 'SQL035%'
|
||||
@ -57,7 +59,7 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
|
||||
o.customer
|
||||
,o.chanwide
|
||||
,o.nursery_region
|
||||
,o.general_region
|
||||
,c.greenhouse_region
|
||||
,m.part_group
|
||||
,m.majg
|
||||
,m.assc
|
||||
@ -73,14 +75,13 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
|
||||
SELECT
|
||||
jsonb_strip_nulls(
|
||||
jsonb_build_object(
|
||||
'customer' ,CASE WHEN GROUPING(customer ) = 0 THEN customer END
|
||||
,'chanwide' ,CASE WHEN GROUPING(chanwide ) = 0 THEN chanwide END
|
||||
,'nursery_region' ,CASE WHEN GROUPING(nursery_region ) = 0 THEN nursery_region END
|
||||
,'general_region' ,CASE WHEN GROUPING(general_region ) = 0 THEN general_region END
|
||||
--,'country' ,CASE WHEN GROUPING(country) = 0 THEN country END
|
||||
,'baseitem' ,CASE WHEN GROUPING(baseitem ) = 0 THEN baseitem END
|
||||
,'v1dataseg' ,CASE WHEN GROUPING(v1dataseg) = 0 THEN v1dataseg END
|
||||
,'v0dataseg' ,CASE WHEN GROUPING(v0dataseg) = 0 THEN v0dataseg END
|
||||
'customer' ,CASE WHEN GROUPING(customer ) = 0 THEN customer END
|
||||
,'chanwide' ,CASE WHEN GROUPING(chanwide ) = 0 THEN chanwide END
|
||||
,'nursery_region' ,CASE WHEN GROUPING(nursery_region ) = 0 THEN nursery_region END
|
||||
,'greenhouse_region' ,CASE WHEN GROUPING(greenhouse_region ) = 0 THEN greenhouse_region END
|
||||
,'baseitem' ,CASE WHEN GROUPING(baseitem ) = 0 THEN baseitem END
|
||||
,'v1dataseg' ,CASE WHEN GROUPING(v1dataseg) = 0 THEN v1dataseg END
|
||||
,'v0dataseg' ,CASE WHEN GROUPING(v0dataseg) = 0 THEN v0dataseg END
|
||||
)
|
||||
) gset
|
||||
,oseas
|
||||
@ -93,14 +94,14 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
|
||||
agg
|
||||
GROUP BY GROUPING SETS (
|
||||
-- oseas baseitem v0datseg chanwide customer region v1dataseg --
|
||||
(oseas, baseitem, v0dataseg, customer )
|
||||
,(oseas, baseitem, customer, v1dataseg )
|
||||
,(oseas, baseitem, v0dataseg, chanwide )
|
||||
,(oseas, baseitem, v0dataseg, chanwide, nursery_region )
|
||||
,(oseas, baseitem, v0dataseg, chanwide, general_region )
|
||||
,(oseas, baseitem, chanwide, v1dataseg )
|
||||
,(oseas, baseitem, v0dataseg, nursery_region )
|
||||
,(oseas, baseitem, v0dataseg, general_region )
|
||||
(oseas, baseitem, chanwide, v0dataseg, customer )
|
||||
,(oseas, baseitem, chanwide, customer, v1dataseg )
|
||||
,(oseas, baseitem, chanwide, v0dataseg )
|
||||
,(oseas, baseitem, chanwide, v0dataseg, nursery_region )
|
||||
,(oseas, baseitem, chanwide, v0dataseg, greenhouse_region )
|
||||
,(oseas, baseitem, chanwide, v1dataseg )
|
||||
,(oseas, baseitem, chanwide, v0dataseg, nursery_region )
|
||||
,(oseas, baseitem, chanwide, v0dataseg, greenhouse_region )
|
||||
)
|
||||
)
|
||||
SELECT
|
||||
@ -129,7 +130,7 @@ CREATE TABLE IF NOT EXISTS rlarp.price_pool_dev AS (
|
||||
-- rlarp.price_pool g
|
||||
--WHERE
|
||||
-- o.version IN ('Actual','Quotes')
|
||||
-- AND g.gset = jsonb_build_object('baseitem',o.baseitem,'v0dataseg',o.v0dataseg,'chanwide','D','general_region','US');
|
||||
-- AND g.gset = jsonb_build_object('baseitem',o.baseitem,'v0dataseg',o.v0dataseg,'chanwide','D','greenhouse_region','US');
|
||||
--
|
||||
--UPDATE
|
||||
-- rlarp.osm_stack o
|
||||
|
Loading…
Reference in New Issue
Block a user