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 +)