0

I have the below table

Item_no item_type measure_name measure_value measure_type
1001 SAR Area 1000 sqft
1001 SAR width 200 mm
1001 SAR breadth 230 cm
1002 SEN diameter 100 mm
1002 SEN height 20 mm
1003 ZPR length 100 mm
1003 ZPR width 200 mm
1003 ZPR height 100 cm

How to get in below table format Item_no item_type Area_value Area_type width_measure_value width_type breadth_value breadth_type diameter_value diameter_type height_value height_type
1001 SAR 1000 sqft 200 mm 230 cm
1002 SEN null null null null null null 100 mm 20 mm . . .

Here item_no and item_name keeps growing with different measure_name,measure_value, measure_type..

How to dynamically frame multiple columns based on above measurements columns.

I am using oracle 19c.

  • Might be useful to reformat that question so we can understand what you're asking. But this link might be useful https://technology.amis.nl/oracle/dynamic-sql-pivoting-stealing-antons-thunder/ – Connor McDonald Jun 15 '23 at 03:02
  • Short answer is Oracle does not support dynamic pivots. You are better solving this problem in whatever client application you are using to access the database (C#, PHP, Java, etc.). If you really must attempt it in the database (don't) then you will either require dynamic SQL or to use something like an XML pivot (see the linked duplicate), but then you would have XML output and not columns. – MT0 Jun 15 '23 at 07:43

0 Answers0