Divides rows within a partition into a specified number of buckets and assigns a bucket number to each row.
INT64Diperbarui: 13 Jun 2026NTILE(num_buckets) OVER ([PARTITION BY partition_expression] ORDER BY sort_expression)Number of buckets to divide the data into
Determines the order before division
Divides data into groups (optional)
1 SELECT 2 name, 3 salary, 4 NTILE(4) OVER (ORDER BY salary) as quartile 5 FROM `project.dataset.employees`;
Divides employees into 4 groups based on salary.
| name | salary | quartile |
|---|---|---|
| David | 50000 | 1 |
| Charlie | 70000 | 2 |
| Bob | 90000 | 3 |
| Alice | 120000 | 4 |
1 SELECT 2 department, 3 name, 4 sales, 5 NTILE(10) OVER (PARTITION BY department ORDER BY sales DESC) as decile 6 FROM `project.dataset.sales_reps`;
Top 10% performers (decile=1) per department.
Sudah paham NTILE? Latih langsung di browser
Latihan interaktif, langsung di browser.