NTILE
Learn NTILE (Window Functions, MySQL) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Introduction NTILE(n) splits the ordered rows of a window into n roughly equal buckets and returns the bucket number (1..n). When rows do not divide evenly, the first buckets get one extra row.