Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Idea: Function to get the column name that has the maximum value

User_1871Aug 13 2024 — edited Aug 13 2024

Input:

Bud_2-1723471126114.png

https://dbfiddle.uk/cRwtWyjo

For each row, I want to select the column name that has the maximum value:

Bud_3-1723471149356.png

It's my understanding there isn't a succinct way to do that, such as a function that takes a list of column names and outputs the name of the column that has the maximum value, like this:

max_col(agr_forest_fish, mining_quarry, mfg, electric, water_sew)

As a novice, I'm wondering if Oracle could be enhanced by adding a function like that.

Comments
Post Details
Added on Aug 13 2024
4 comments
522 views