Home » SQL & PL/SQL » SQL & PL/SQL » Greatest column name with value
Greatest column name with value [message #245937] Tue, 19 June 2007 06:42 Go to next message
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 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
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
Re: Greatest column name with value [message #245967 is a reply to message #245957] Tue, 19 June 2007 07:38 Go to previous messageGo to next message
iamdurai
Messages: 96
Registered: April 2007
Location: Chennai
Member

Thanks Michel,

please give me some meaning of ,

1) col c fold_after
2) col l fold_after
3) set head off

if possible.

Reds
Thangam.
Re: Greatest column name with value [message #245989 is a reply to message #245967] Tue, 19 June 2007 09:01 Go to previous message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
COLUMN
SET HEADING

Regards
Michel
Previous Topic: Sending e-mail from PL/SQL with attachment files
Next Topic: Help me with this Query.
Goto Forum:
  


Current Time: Sun Dec 04 08:50:10 CST 2016

Total time taken to generate the page: 0.04532 seconds