Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL LEAST Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: LEAST

Definition:
The Oracle/PLSQL LEAST function returns the least or smallest value in a list of values or expressions. Oracle compares the expressions using nonpadded comparison semantics.

If the datatypes of the values or expressions are different, all of the values and expressions will be converted to the same datatype as value_1 is.

If the comparison is between characters (quoted strings), one character will be considered "less" than another character if it has a lower character set value. This is usually based on the ASCII value, but may differ for other character sets or Unicode values.

The LEAST function returns NULL whenever it receives a NULL parameter, regardless of the particular value that is NULL. (In general, functions that take a set of inputs will return NULL when a deciding input is NULL.)

Example Syntax:

LEAST( value_1, value_2, ... value_n ) 


value_1, value_2, ... value_n are the values or expressions that are evaluated by the LEAST function.


Example Usage:

LEAST(7, 19, 85, 2)                  returns '2'
LEAST('2', '19', '6', '14') returns '14'
LEAST('dallas', 'seattle', 'miami') returns 'dallas'
LEAST('dallas', 'dulles', 'dullus') returns 'dallas'
LEAST('blue', 'blew', 'blow') returns 'blew'


Notes:
  1. If the value returned by this function is character data, its datatype is always VARCHAR2.
  2. Do not confuse LEAST with MAX. LEAST returns the least of the list of expressions, while MAX returns the maximum value of expressions and is normally used as an aggregate or analytic function.
  3. If LEAST is used to compare dates it will return the earliest (oldest) date.



Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 65 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?