Returns the approximate most frequently occurring elements along with their counts. Uses a highly efficient approximate algorithm for large datasets.
ARRAY<STRUCT<value T, count INT64>>Diperbarui: 13 Jun 2026APPROX_TOP_COUNT(expression, number)The column or expression to find the top frequent values for
The number of top values to return
1 SELECT 2 APPROX_TOP_COUNT(product_name, 5) as top_products 3 FROM `project.dataset.orders`;
Finds the 5 products that are ordered most frequently.
| top_products |
|---|
| [{value: "iPhone 15", count: 15230}, |
| {value: "MacBook Pro", count: 8450}, |
| {value: "AirPods", count: 7890}, |
| {value: "iPad", count: 6540}, |
| ... 1 baris lainnya |
1 SELECT 2 top_keyword.value as keyword, 3 top_keyword.count as search_count 4 FROM `project.dataset.search_logs`, 5 UNNEST(APPROX_TOP_COUNT(search_query, 10)) as top_keyword;
Finds the 10 most popular search keywords.
| keyword | search_count |
|---|---|
| gaming laptop | 125000 |
| iphone 15 | 98000 |
| nike shoes | 87500 |
| branded bag | 76000 |
1 SELECT 2 service_name, 3 APPROX_TOP_COUNT(error_code, 3) as top_errors 4 FROM `project.dataset.error_logs` 5 WHERE DATE(timestamp) = CURRENT_DATE() 6 GROUP BY service_name;
Finds the 3 most frequent errors per service.
| service_name | top_errors |
|---|---|
| auth-service | [{value: "AUTH_001", count: 5230}, ...] |
| api-gateway | [{value: "TIMEOUT", count: 3450}, ...] |
Sudah paham APPROX_TOP_COUNT? Latih langsung di browser
Latihan interaktif, langsung di browser.