0

I have a table in Oracle which is like this, and I don’t know how many ‘Vendor’ is there, this keeps on growing ( but will grow around 50). Basically same products from different Vendors are sourced. The same Product is identified by the same ‘Alias’.

Alias Product_ID Vendor
123 abc001 V1
123 abc002 V2
123 abc003 V3
456 abc004 V1
456 abc005 V2
456 abc006 V3

I want to represent the data like this:

Alias V1 V2 V3
123 abc001 abc002 abc003
456 abc004 abac005 abc006

Please note that I don’t know how many vendors will get added tomorrow, so my query should work in such a way that it gives an additional column with the same query if a new vendor is added tomorrow.

I need to try this out in Oracle.

Any help is greatly appreciated.

Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55
kumar
  • 23
  • 3
  • 1
    When you will have 50 vendors, your "table" will grow to 50 columns. The only reason to do this kind of pivoting is for a final report (for business user consumption); but what business user is able to read and understand a table with 50 columns? What I'm saying is that the task itself is nonsensical - whoever requested it doesn't know what they are doing. Can you talk them out of it? –  Nov 27 '21 at 05:29
  • 1
    Also - I just edited your post (minimally) to show how to format code. Hit the Edit button and do the same to the other code fragments. Without formatting the question is unreadable. –  Nov 27 '21 at 05:31

0 Answers0