Aggregate
Snowflake
PERCENTILE_CONT
Menghitung percentile continuous (interpolasi) dari nilai numerik. Memberikan nilai yang mungkin tidak ada di dataset (hasil interpolasi).
Tipe hasil:
FLOATDiperbarui: 6 Jan 2026Syntax
SQL
PERCENTILE_CONT(percentile) WITHIN GROUP (ORDER BY expression)Parameter
percentileFLOATwajib
Nilai percentile antara 0 dan 1 (misal: 0.5 untuk median)
expressionnumericwajib
Kolom numerik yang akan dihitung percentilenya
Contoh Penggunaan
Menghitung Median (P50)
SQL
1 SELECT 2 PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY salary) as median_salary 3 FROM employees;
Menghitung median gaji. PERCENTILE_CONT(0.5) equivalent dengan MEDIAN.
Hasil
75000.00
Distribusi Percentile Lengkap
SQL
1 SELECT 2 PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY response_time) as p25, 3 PERCENTILE_CONT(0.50) WITHIN GROUP (ORDER BY response_time) as p50, 4 PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY response_time) as p75, 5 PERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY response_time) as p95, 6 PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY response_time) as p99 7 FROM api_logs;
Menganalisis distribusi response time dengan berbagai percentile.
Hasil
| P25 | P50 | P75 | P95 | P99 |
|---|---|---|---|---|
| 50.25 | 120.50 | 250.75 | 850.00 | 1500.00 |
Percentile per Kategori
SQL
1 SELECT 2 category, 3 PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY price) as median_price, 4 PERCENTILE_CONT(0.9) WITHIN GROUP (ORDER BY price) as p90_price 5 FROM products 6 GROUP BY category;
Menghitung median dan P90 harga per kategori produk.