Learn SQL By Doing - Practice NTILE Function Queries Online

PHOTO EMBED

Tue Jul 25 2023 00:43:35 GMT+0000 (Coordinated Universal Time)

Saved by @vnmshenoy #undefined

​SELECT name,
genre,
size,
ntile(4) over(order by size desc)
from game

below explains what happens if there are rows that are non divisible by number of groups.

https://learnsql.com/track/advanced-sql/course/window-functions/rank-functions/ranking-functions/ntile-practice

eg says you have 11 records and we want 5 groups, then first group will get 3 records and remaining will get 2 records
content_copyCOPY

Learn how NTile can help you create groups

https://learnsql.com/track/advanced-sql/course/window-functions/rank-functions/ranking-functions/ntile