Home » SQL & PL/SQL » SQL & PL/SQL » find max val in rows?
find max val in rows? [message #248107] Thu, 28 June 2007 01:44 Go to next message
muddasani.s
Messages: 10
Registered: June 2007
Junior Member

hi

how to find out the max value in the row wise records

i.e

id sal1 sal2 sal3
1 2000 3000 2500
2 3880 4560 2098

this type of out put i want

id sal1 sal2 sal3 max(sal1,sal2,sal3)
1 2000 3000 2500 3000
2 3880 4560 2098 4560


plz give me the explanation....

thx
Re: find max val in rows? [message #248108 is a reply to message #248107] Thu, 28 June 2007 01:46 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
GREATEST.

SQL> SELECT GREATEST (2000, 3000, 2500) gr
  2  FROM   DUAL
  3  /

        GR
----------
      3000

SQL> SELECT GREATEST (3880, 4560, 2098) gr
  2  FROM   DUAL
  3  /

        GR
----------
      4560

MHE

[Updated on: Thu, 28 June 2007 01:47]

Report message to a moderator

Re: find max val in rows? [message #248109 is a reply to message #248107] Thu, 28 June 2007 01:49 Go to previous messageGo to next message
caliguardo
Messages: 107
Registered: February 2007
Location: Chennai
Senior Member

Try this
select id,sal1,sal2,sal3,greatest(sal1,sal2,sal3) from table_name;




Sorry Maaher, I didn't see your reply.

[Updated on: Thu, 28 June 2007 01:50]

Report message to a moderator

Re: find max val in rows? [message #248113 is a reply to message #248109] Thu, 28 June 2007 01:53 Go to previous message
muddasani.s
Messages: 10
Registered: June 2007
Junior Member

hi mhe
very great for me..

thx
srinu
Previous Topic: Triggers -Help
Next Topic: iterating over columns
Goto Forum:
  


Current Time: Fri Dec 02 19:04:49 CST 2016

Total time taken to generate the page: 0.17220 seconds