Quick Search:
 
 The Oracle PL/SQL LAST_VALUE Function      [Return To Index] Jump to:  

Term: LAST_VALUE

Definition:
The Oracle PL/SQL LAST_VALUE function is an analytic function which selects the last record from an ordered set of rows. If the last value in the set is NULL, then the function returns NULL. If you specify IGNORE NULLS, then LAST_VALUE returns the first non-null value in the set, or NULL if all values are null.

Example Syntax:

LAST_VALUE(EXPR [INGORE NULLS]) OVER (analytic_clause [windowing_clause])


The windowing clause will further increase or decrease the partition or range for analytic action. By default, it is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. Other values can be RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING and RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING.

Example Usage:

SELECT last_name, salary, hire_date, LAST_VALUE(hire_date)
OVER (ORDER_BY salary ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS lv
FROM (SELECT * FROM employees
WHERE department_id = 90
ORDER_BY hire_date);



Related Links:

Related Code Snippets:
  • LAST_VALUE - Returns the last value in an ordered set of values. If the last value in the set is n...
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org