Home » SQL & PL/SQL » SQL & PL/SQL » to find greatest value
to find greatest value [message #21755] Wed, 28 August 2002 07:50 Go to next message
Victoria
Messages: 152
Registered: July 2002
Senior Member
Hi,
I have one cursor fetching 100 columns per row.
all are same datatype.
Now i want to find the greatest & least value in the fetched columns for each row.....
Can any one tell me the simplest way to do that???
Thanks in advance
Victoria
Re: to find greatest value [message #21760 is a reply to message #21755] Wed, 28 August 2002 12:39 Go to previous messageGo to next message
Su
Messages: 154
Registered: April 2002
Senior Member
Check for GREATEST() and LEAST() functions in ORACLE.
For example, check the following.

SQL> select greatest(10,20) from dual;

GREATEST(10,20)
---------------
20

SQL> select least(10,20) from dual;

LEAST(10,20)
------------
10

SQL>

Hope this helps. Good luck :)
Re: to find greatest value [message #21762 is a reply to message #21755] Wed, 28 August 2002 13:11 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Not pretty but...

for r in (select * from t) loop
  v_least := least(r.col1, r.col2, ..., r.col100);
  v_greatest := greatest(r.col1, r.col2, ..., r.col100);
end loop;
Previous Topic: oracle cursors not working well
Next Topic: extracted report to be mailed in *.csv format
Goto Forum:
  


Current Time: Thu Apr 25 13:06:36 CDT 2024