Hi
With my data_to_pivot I wish to pivot rows for each pair key-value to columns respectively.
I'm using oracle 11G. Thank you.
--sample data
WITH data_to_pivot AS
(
SELECT date '2021-02-15' as start_date, date '2999-12-31' as end_date, 'Product_Code' dim_name_0, 'XMAS1000' as idx_name_0,'Attribute_1' as dim_name_1, 'Primary' as idx_name_1,'Attribute_2' as dim_name_2 ,'Single Uplink' as idx_name_2,'Attribute_3' as dim_name_3 , 1 as idx_name_3,'Attribute_4' as dim_name_4 , '100 Mbps' as idx_name_4,'Type' as dim_name_5, 'Part_Number' as idx_name_5, 'XMTC001' as string_value FROM DUAL UNION
SELECT date '2021-02-15' as start_date, date '2999-12-31' as end_date, 'Product_Code' dim_name_0, 'XMAS1000' as idx_name_0,'Attribute_1' as dim_name_1, 'Primary' as idx_name_1,'Attribute_2' as dim_name_2 ,'Single Uplink' as idx_name_2,'Attribute_3' as dim_name_3 , 2 as idx_name_3,'Attribute_4' as dim_name_4 , '200 Gbps' as idx_name_4,'Type' as dim_name_5, 'Part_Number' as idx_name_5 , 'XMTC002' as string_value FROM DUAL UNION
--
SELECT date '2021-02-15' as start_date, date '2999-12-31' as end_date, 'Product_Code' dim_name_0, 'XMAS1000' as idx_name_0,'Attribute_1' as dim_name_1, 'Primary' as idx_name_1,'Attribute_2' as dim_name_2 ,'Single Uplink' as idx_name_2,'Attribute_3' as dim_name_3 , 1 as idx_name_3,'Attribute_4' as dim_name_4 , '100 Mbps' as idx_name_4,'Type' as dim_name_5, 'PCMS_Description' as idx_name_5 , 'BT BROADBAND UPLINK Z1 100M' as string_value FROM DUAL UNION
SELECT date '2021-02-15' as start_date, date '2999-12-31' as end_date, 'Product_Code' dim_name_0, 'XMAS1000' as idx_name_0,'Attribute_1' as dim_name_1, 'Primary' as idx_name_1,'Attribute_2' as dim_name_2 ,'Single Uplink' as idx_name_2,'Attribute_3' as dim_name_3 , 2 as idx_name_3,'Attribute_4' as dim_name_4 , '200 Gbps' as idx_name_4,'Type' as dim_name_5, 'PCMS_Description' as idx_name_5 , 'BT BROADBAND UPLINK Z2 200G' as string_value FROM DUAL
)SELECT *
FROM data_to_pivot
order by string_value;
Expecting this result
