Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

MIN windowing function

Syntax

MIN ( { [ALL] expression } ) OVER ( [ partition_by_clause ] order_by_clause )

Description

The aggregate function MIN returns the minimum of the values in a group. The argument column_ref or expression can be of any type. The result of the function is of the same data type as that of the argument. The result can have a null value.

Example

select empno, deptno, projno, sal, min(sal) over (partition by deptno, projno order by projno) min_proj_sal from emp;

EMPNO DEPTNO PROJNO SAL MIN_PROJ_SAL

----- ------ ------ --- -----------

7782 10 101 2450.00 2450.000000

7839 10 102 5000.00 1300.000000

7934 10 102 1300.00 1300.000000

7566 20 101 2975.00 800.000000

7329 20 101 800.00 800.000000

7876 20 101 1100.00 800.000000

7788 20 101 3000.00 800.000000

7902 20 101 3000.00 800.000000

7698 30 101 2850.00 2850.000000

7844 30 102 1500.00 950.000000

7900 30 102 950.00 950.000000

7521 30 103 1250.00 1250.000000

7654 30 103 1250.00 1250.000000

7499 30 103 1600.00 1250.000000

See Also

TOCIndex