Hi friends today we will discuss about NTILE in Oracle:
Syntax:
SELECT NTILE(NUMBER) OVER (ORDER BY <COLUMN>) FROM TABLE;
Example:
SELECT ename, sal, NTILE(2) OVER (ORDER BY sal asc) AS quartile
FROM EMP
ORDER BY ename, sal, quartile;
o/p:
Syntax:
SELECT NTILE(NUMBER) OVER (ORDER BY <COLUMN>) FROM TABLE;
Example:
SELECT ename, sal, NTILE(2) OVER (ORDER BY sal asc) AS quartile
FROM EMP
ORDER BY ename, sal, quartile;
o/p:
empname | sal | quartile | |||||||||
11raj | 5000 | 2 | |||||||||
ADAMS | 1100 | 1 | |||||||||
ALLEN | 1600 | 2 | |||||||||
BLAKE | 2850 | 2 | |||||||||
CLARK | 2450 | 2 | |||||||||
FORD | 3000 | 2 | |||||||||
JAMES | 950 | 1 | |||||||||
JONES | 2975 | 2 | |||||||||
MARTIN | 1250 | 1 | |||||||||
MILLER | 1300 | 1 | |||||||||
SCOTT | 3000 | 2 | |||||||||
SMITH | 800 | 1 | |||||||||
TURNER | 1500 | 1 | |||||||||
WARD | 1250 | 1 |
No comments:
Post a Comment