to display maximum value [message #169974] |
Mon, 01 May 2006 04:41 |
shalumadhu
Messages: 6 Registered: February 2006 Location: hyd
|
Junior Member |
|
|
hi all,
i have 2 fileds in 2 different tables.
i have to diaply field by comparing the fields in the 2 tables (comparing which field is having maximum value).
can any one of u help me.
Thnaks and Regards,
madhu
|
|
|
Re: to display maximum value [message #169977 is a reply to message #169974] |
Mon, 01 May 2006 06:29 |
orausern
Messages: 826 Registered: December 2005
|
Senior Member |
|
|
Use the function called GREATEST..
for example, i created copy of emp table as emp1 , changed value of comm column and got expected result as under:
1* select ENAME,COMM from emp where ename='ALLEN'
SQL> /
ENAME COMM
---------- ----------
ALLEN 300
SQL> select ENAME,COMM from emp1 where ename='ALLEN';
ENAME COMM
---------- ----------
ALLEN 400
SQL> select greatest(emp.comm,emp1.comm) from
SQL> emp,emp1 where
SQL> emp.empno=emp1.empno
SQL> and emp.ename='ALLEN'
SQL> /
GREATEST(EMP.COMM,EMP1.COMM)
----------------------------
400
|
|
|
|
|
|