Window

CUME_DIST

DuckDBDuckDB

Menghitung distribusi kumulatif - proporsi baris yang memiliki nilai kurang dari atau sama dengan baris saat ini.

Tipe hasil: DOUBLEDiperbarui: 6 Jan 2026

Syntax

SQL
CUME_DIST() OVER ([PARTITION BY col] ORDER BY col)

Parameter

ORDER BYclausewajib

Menentukan urutan untuk distribusi kumulatif

PARTITION BYclauseopsional

Opsional. Membagi hasil menjadi partisi

Contoh Penggunaan

Distribusi Kumulatif Score

SQL
1SELECT
2 name,
3 score,
4 CUME_DIST() OVER (ORDER BY score) as cume_dist,
5 ROUND(CUME_DIST() OVER (ORDER BY score) * 100, 1) as cumulative_pct
6FROM students;

Menghitung berapa persen siswa dengan score <= saat ini.

Hasil
namescorecume_distcumulative_pct
Ani700.2525.0
Budi800.5050.0
Citra900.7575.0
Deni951.00100.0

Perbandingan PERCENT_RANK vs CUME_DIST

SQL
1SELECT
2 name,
3 score,
4 PERCENT_RANK() OVER (ORDER BY score) as prank,
5 CUME_DIST() OVER (ORDER BY score) as cdist
6FROM students;

Membandingkan kedua fungsi untuk memahami perbedaannya.

Hasil
namescoreprankcdist
Ani700.000.25
Budi800.330.50
Citra900.670.75
Deni951.001.00

Revenue Milestone Analysis

SQL
1SELECT
2 month,
3 revenue,
4 CUME_DIST() OVER (ORDER BY revenue) as revenue_percentile
5FROM monthly_revenue
6ORDER BY revenue;

Menganalisis distribusi revenue bulanan.