Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

COUNT windowing function

Syntax

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

Description

The aggregate function COUNT returns the number of 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, first_value(empno) over (partition by deptno, projno order by sal) lowest_salary from emp;

EMPNO DEPTNO PROJNO EMP_PER_PROJ

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

7782 10 101 1

7839 10 102 2

7934 10 102 2

7566 20 101 5

7329 20 101 5

7876 20 101 5

7788 20 101 5

7902 20 101 5

7698 30 101 1

7844 30 102 2

7900 30 102 2

7521 30 103 3

7654 30 103 3

7499 30 103 3

See Also

TOCIndex