Re: get the column_name of the maximum value for a row

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Fri, 18 Sep 2009 06:18:21 +0200
Message-ID: <4ab30a0d$0$31051$426a74cc_at_news.free.fr>


"Ninja Li" <nickli2000_at_gmail.com> a �crit dans le message de news: 328aa22c-967d-4ac1-b453-8a73b314795b_at_33g2000vbe.googlegroups.com...
| Hi,
|
| I want to get the column_name of the maximum value of a row. To
| simplify, the table has the following format and values, with
| input_date being unique. The columns evaluated are the "value_"
| columns.
|
| input_date value_1 value_2 value_3 ** maximum
| value ** maximum value_column
| 01-SEP-09 10 15 8
| 15 value_1
| 02-SEP-09 12 5 18
| 18 value_3
| 03-SEP-09 9 12 12
| 12 value_2
| ...........
|
| The desired output is:
| 01-SEP-09 15 value_1
| 02-SEP-09 18 value_3
| 03-SEP-09 12 value_3
| ..........
|
| Is the problem solvable using plain SQL? Or do I need to use PL/
| SQL? The database is Oracle 9i.
|
| Thanks in advance.
|
| Nick
|
|
|

Use DECODE.
What should be the value if 2 or more columns have the highest value?

Regards
Michel Received on Thu Sep 17 2009 - 23:18:21 CDT

Original text of this message