get the column_name of the maximum value for a row
From: Ninja Li <nickli2000_at_gmail.com>
Date: Thu, 17 Sep 2009 14:45:48 -0700 (PDT)
Message-ID: <328aa22c-967d-4ac1-b453-8a73b314795b_at_33g2000vbe.googlegroups.com>
Hi,
Date: Thu, 17 Sep 2009 14:45:48 -0700 (PDT)
Message-ID: <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 Received on Thu Sep 17 2009 - 16:45:48 CDT