Oracle Analytic Functions
Oracle Analytic Functions compute an aggregate value based on a group of rows. It opens up a whole new way of looking at the data. They differ from aggregate functions in that they return multiple rows for each group. The group of rows is called a window and is defined by the analytic clause. For each row, a sliding window of rows is defined. The window determines the range of rows used to perform the calculations for the current row.
Oracle provides many Analytic Functions such as
AVG, CORR, COVAR_POP, COVAR_SAMP, COUNT, CUME_DIST, DENSE_RANK, FIRST, FIRST_VALUE, LAG, LAST, LAST_VALUE, LEAD, MAX, MIN, NTILE, PERCENT_RANK, PERCENTILE_CONT, PERCENTILE_DISC, RANK, RATIO_TO_REPORT, STDDEV, STDDEV_POP, STDDEV_SAMP, SUM, VAR_POP, VAR_SAMP, VARIANCE.
The Syntax of analytic functions:
Analytic functions take 0 to 3 arguments.
SELECT ename, deptno, sal,
OVER (ORDER BY deptno, ename) AS Running_Total,
OVER ( PARTITION BY deptno
ORDER BY ename) AS Dept_Total,
OVER (PARTITION BY deptno
ORDER BY ename) As Sequence_No
ORDER BY deptno, ename;
For more details visit:
Posted by Saurav Mitra