What is the difference between Ntilte, PERCENT_RANK
PERCENT_RANK: this function will give us the percentage of the employees which have this salary and above.
i.e at emp id 12 row: the percentage of employees having salary more than 2220 is 28.57% of total employed, these kinds of functions output is generally used as the input for bars graph/ pie chart report.
select EmployID,EmployName,EmploySalary,FORMAT(PERCENT_RANK() over(order by employsalary desc),'P') R from Employ
Ntilte: This function is used to distribute the rows into a specified number of groups based on some order and partition. The group number starts from 1. i.e. you can group out 1 dataset into get top 25% of the employ which are getting maximum salary, to extract this data you can divide the data into 4 parts and select the 1st section from the data
Below is the query for the same:
select EMPLOYEEID,EMPLOYEENAME,EMPLOYEE SALARY,NTILE(4) OVER(ORDER BY EMPLOYSALARY DESC) AS Quartile from EMPLOY