sql - Oracle - Query to join fact table to bridge table and show bridge group rows in one row? - Database Administrators Stack Exchange
i have data warehouse one-to-many relationship:
"fact" table contains: product_group_id "product_bridge" table contains: product_group_id, product_id "product" table contains: product_id, product_name, other product attributes..
i've inserted data relevant tables, how can query database , retrieve products product group in 1 row result? i've never used bridge table before , not find decent/helpful examples online how query between bridge/fact/dimensions.
i.e. desired result like:
product_group_id product_id product_name product_id_1 product_name1 product_id_n product_name_n
any suggestions appreciated.
based on example output can use listagg. basic query can add whatever other criteria is;
select distinct (p.product_group_id ||' '|| listagg(c.product_id||' '||c.product_name, ' ') within group(order p.product_group_id, c.product_id) on (partition p.product_group_id)) product c inner join product_bride p on c.product_id = p.product_id
if need more attributes product need concatenate them in listagg. haven't included join fact table can included if need it.
Comments
Post a Comment