From 01b70dce3c972944c929328968f1c882afc4bace Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 11 Jan 2021 23:49:44 -0500 Subject: [PATCH] work on aggregating to the price point --- db_schema/extract_for_customer_facing.pg.sql | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/db_schema/extract_for_customer_facing.pg.sql b/db_schema/extract_for_customer_facing.pg.sql index f794138..6099a6f 100644 --- a/db_schema/extract_for_customer_facing.pg.sql +++ b/db_schema/extract_for_customer_facing.pg.sql @@ -197,9 +197,20 @@ FROM --SELECT * FROM items_init where seq = 1 --SELECT * FROM items where seq = 1 ----join conversion back to data initial part link------------------------------ +,joinback_init AS ( SELECT - i.* - ,c.* + i.stlc + ,i.coltier + ,i.branding + ,i.accs + ,i.suffix + ,i.pckg + ,i.col + ,i.vol_uom + ,i.vol_qty + ,i.price + ,c.nm + ,c.dm ,l.clist FROM items_init i @@ -213,3 +224,13 @@ ORDER BY i.stlc ,i.coltier ,i.col +) +,agg_levels AS ( + SELECT + stlc + ,jsonb_agg(DISTINCT coltier) coltier + ,jsonb_agg(branding) + ,jsonb_agg(DISTINCT + ,jsonb_agg(DISTINCT + ,jsonb_agg(DISTINCT +)