Calculates approximate quantile boundaries from numeric data. Uses an efficient approximate algorithm for large datasets, returning an array with n+1 elements.
ARRAY<T>Diperbarui: 13 Jun 2026APPROX_QUANTILES(expression, number)The numeric column or expression to compute quantiles for
The number of quantiles desired (n produces n+1 boundaries)
1 SELECT 2 APPROX_QUANTILES(salary, 4) as salary_quartiles 3 FROM `project.dataset.employees`;
Calculates the min, Q1, median, Q3, and max from salary values.
| salary_quartiles |
|---|
| [5000000, 8500000, 12000000, 18000000, 45000000] |
1 SELECT 2 APPROX_QUANTILES(response_time_ms, 100)[OFFSET(50)] as p50, 3 APPROX_QUANTILES(response_time_ms, 100)[OFFSET(90)] as p90, 4 APPROX_QUANTILES(response_time_ms, 100)[OFFSET(99)] as p99 5 FROM `project.dataset.api_logs`;
Retrieves the 50th, 90th, and 99th percentiles of response time.
| p50 | p90 | p99 |
|---|---|---|
| 120 | 450 | 1250 |
1 SELECT 2 product_category, 3 APPROX_QUANTILES(price, 4) as price_distribution 4 FROM `project.dataset.products` 5 GROUP BY product_category;
Views the price distribution per product category.
| product_category | price_distribution |
|---|---|
| Electronics | [99000, 500000, 1500000, 5000000, 25000000] |
| Fashion | [50000, 150000, 350000, 750000, 5000000] |
1 SELECT 2 department, 3 APPROX_QUANTILES(salary, 2)[OFFSET(1)] as median_salary 4 FROM `project.dataset.employees` 5 GROUP BY department 6 ORDER BY median_salary DESC;
Calculates the median salary per department.
| department | median_salary |
|---|---|
| Engineering | 15500000 |
| Marketing | 12000000 |
| Operations | 9500000 |
Sudah paham APPROX_QUANTILES? Latih langsung di browser
Latihan interaktif, langsung di browser.