Aggregate

CORR

BigQueryBigQuery

Menghitung koefisien korelasi Pearson antara dua kolom numerik.

Tipe hasil: FLOAT64

Syntax

SQL
CORR(x, y)

Parameter

xFLOAT64wajib

Kolom numerik pertama

yFLOAT64wajib

Kolom numerik kedua

Contoh Penggunaan

Calculate Correlation

SQL
1SELECT CORR(price, quantity) AS price_qty_corr
2FROM sales;

Korelasi antara harga dan kuantitas.

Hasil
price_qty_corr: -0.75

Correlation by Category

SQL
1SELECT
2 category,
3 CORR(ad_spend, revenue) AS roi_correlation
4FROM marketing
5GROUP BY category;

Korelasi ad spend dengan revenue per kategori.

Hasil
(correlations by category)