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

Term: MIN

Definition:
The Oracle PL/SQL MIN function is used to get the minimum value of a column. Like the MAX function, the MIN function also shows both aggregate and analytic behavior.

Example Syntax

MIN(expression) OVER (analytic clause)


Example Usage

Aggregate: The below SQL retrieves the minimum salary in each job category from EMPLOYEE table.

SELECT JOB_ID, MIN(SALARY)
FROM EMPLOYEE
GROUP_BY JOB_ID


Analytic: The below SQL displays the most experienced employee in each job category.

SELECT ENAME, JOB_ID, HIRE_DATE
FROM
(
SELECT ENAME, JOB_ID, HIRE_DATE, MIN(HIRE_DATE) OVER (PARTITION BY JOB_ID) MIN_HIREDATE
FROM EMPLOYEE
)
WHERE TRUNC(HIRE_DATE)=TRUNC(MIN_HIREDATE)



Related Links:

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