Ntile

Description: Divides an ordered data set into a number of buckets indicated by expr and assigns the appropriate bucket number to each row. The buckets are numbered 1 through expr. The expr value must resolve to a positive constant for each partition.

NTILE (<expression>) OVER ([query_partition_clause] <order BY clause>)
 
conn oe/oe
 
SELECT last_name, salary,
NTILE(4) OVER (ORDER BY salary DESC) AS quartile
FROM employees
WHERE department_id = 100;

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.