My dataset is not exactly like EAV format, but it’s somewhat similar; here’s the data:

In the format I need is as follows:

For every EN_NO group I need the data in above format. If group on EN_NO > 1 then respestive product key should go to respestive product column otherwise not (for e.g. EN_NO 4 and 5).
I hope I am clear. Data is in a Qracle table, please suggest a query to get the data in the format I need.
Thanks,
Prakash
I would highly recommend altering your table structure. At present you have two pieces of information tied into a single field. This is a SQL Anti-Pattern and destroys the ability of Oracle to user certain optimisations.
Instead, please consider splitting “PROD_KEY” into two fields (PRODUCT_TYPE = Prod_A, etc) (SUB_PRODUCT_ID = 1, 2, 3, etc). Or, to cause less potential change across the database, simply add the PRODUCT_TYPE to your current table.
That said, using your current structure…
This works when you know specifically what columns you need as output. If you need the code to adapt to having
Prod_D, etc, then you need to write code that writes code (Dynamic SQL).