Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

ANALYTICAL FUNCTION:

It is like a group function, group function reduces the number of rows in the column.

But analytical function does not reduce the column.

 Rank()
 Dense_Rank()
 Lead()
 Lag()
 Row_number()
 Listagg()

Rank():

If the values are the same it will give the same rank but it will skip the next consecutive rank.

Select first_name, salary, rank() over(order by salary desc) from employees;

Dense_rank():

If the values are same, it will give the same rank and it won’t skip the consecutive rank.

Select first_name, salary, dense_rank() over(order by salary desc) from employees;

Lead():

It will take values from next row.

Select first_name, lead(first_name,2,’abc’) over (order by first_name) from employees;

Lag():

It will take values from previous row.

Select first_name, lag(first_name, 2, ‘abc’) over(order by first_name) from employees;

Row_number():

Select first_name, salary, row_number() over(order by salary) from employees;

Listagg():

It is a feature of 11g version. So can’t be used in 10g.

( vertical into horizontal)

Select listagg( first_name) within group (order by first_name) from employees;

Select listagg( first_name,’,’) within group( order by first_name) from employees;

You might also like