Oracle Conversion Function - Oracle/PLSQL GREATEST Function






This Oracle tutorial explains how to use the Oracle/PLSQL GREATEST function.

GREATEST(a, b, ...) returns the greatest value of the function arguments.

Syntax

The syntax for the Oracle/PLSQL GREATEST function is:

GREATEST( expr1, expr2, ... expr_n )

expr1, expr2, . expr_n are evaluated by the GREATEST function.

If the data types of the expressions are different, all expressions will be converted to whatever datatype expr1 is.

Example


SQL> select greatest(12*12,148/2,73) from dual;
--  w w  w .  j a  v  a 2s  . c  o m
GREATEST(12*12,148/2,73)
------------------------
                     144

SQL>
GREATEST('2', '5', '12', '3')
-----------------------------
                          '5'
 
GREATEST('apples', 'oranges', 'bananas')
---------------------------------------
                               'oranges'