Greatest column name with value [message #245937] |
Tue, 19 June 2007 06:42  |
iamdurai
Messages: 96 Registered: April 2007 Location: Chennai
|
Member |
 
|
|
Hi,
This is my table and values,i want to findout which one is greatest value, i got the query.But my problem is how can i print the Column name.
SQL> select * from grt;
A B C D
--- --- --- ---
2 1 4 0
SQL> select greatest(a,b,c,d) from grt;
GREATEST(A,B,C,D)
-----------------
4
I need output like this with column name.
C
----
4
like this.
please advice me.
Reds
Thangam.
|
|
|
Re: Greatest column name with value [message #245957 is a reply to message #245937] |
Tue, 19 June 2007 07:20   |
 |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
SQL> col c fold_after
SQL> col l fold_after
SQL> set head off
SQL> select decode(greatest(a,b,c,d),a,'A',b,'B',c,'C',d,'D') c,
2 '-' l,
3 to_char(greatest(a,b,c,d))
4 from t;
C
-
4
1 row selected.
Regards
Michel
|
|
|
|
|