Aggregate
BigQuery
STDDEV_SAMP
Calculates the sample standard deviation of numeric values. Uses the N-1 divisor formula (Bessel's correction), suitable for sample data that represents a larger population.
Tipe hasil:
FLOAT64Diperbarui: 13 Jun 2026Syntax
SQL
STDDEV_SAMP(expression)Parameter
expressionnumericwajib
A numeric column or expression for which to calculate the sample standard deviation
Contoh Penggunaan
Sample Standard Deviation for Survey Data
SQL
1 SELECT 2 survey_question, 3 AVG(response_score) as avg_score, 4 STDDEV_SAMP(response_score) as score_variability, 5 COUNT(*) as response_count 6 FROM `project.dataset.survey_responses` 7 GROUP BY survey_question 8 ORDER BY score_variability DESC;
Analyzes variability in survey responses (a sample from a population).
Hasil
| survey_question | avg_score | score_variability | response_count |
|---|---|---|---|
| satisfaction | 4.2 | 1.15 | 2500 |
| recommend | 4.5 | 0.89 | 2450 |
| usability | 3.8 | 1.42 | 2480 |
A/B Test Analysis
SQL
1 SELECT 2 experiment_group, 3 AVG(conversion_value) as avg_value, 4 STDDEV_SAMP(conversion_value) as value_stddev, 5 COUNT(*) as sample_size, 6 STDDEV_SAMP(conversion_value) / SQRT(COUNT(*)) as standard_error 7 FROM `project.dataset.ab_test_results` 8 GROUP BY experiment_group;
Calculates standard error for A/B test analysis.
Hasil
| experiment_group | avg_value | value_stddev | sample_size | standard_error |
|---|---|---|---|---|
| control | 125.50 | 45.20 | 5000 | 0.64 |
| treatment | 142.30 | 48.50 | 5000 | 0.69 |
Quality Control with Confidence Interval
SQL
1 SELECT 2 product_line, 3 AVG(weight_grams) as mean_weight, 4 STDDEV_SAMP(weight_grams) as weight_stddev, 5 AVG(weight_grams) - 1.96 * STDDEV_SAMP(weight_grams) / SQRT(COUNT(*)) as ci_lower, 6 AVG(weight_grams) + 1.96 * STDDEV_SAMP(weight_grams) / SQRT(COUNT(*)) as ci_upper 7 FROM `project.dataset.production_samples` 8 GROUP BY product_line;
Calculates a 95% confidence interval for quality control.
Hasil
| product_line | mean_weight | weight_stddev | ci_lower | ci_upper |
|---|---|---|---|---|
| Product A | 500.2 | 5.5 | 499.1 | 501.3 |
| Product B | 250.5 | 3.2 | 249.9 | 251.1 |
Pertanyaan Umum tentang STDDEV_SAMP
Apa itu fungsi STDDEV_SAMP di BigQuery?
Calculates the sample standard deviation of numeric values. Uses the N-1 divisor formula (Bessel's correction), suitable for sample data that represents a larger population. Di BigQuery, fungsi STDDEV_SAMP termasuk dalam kelompok fungsi yang sering digunakan untuk mengolah dan menganalisis data secara efisien.
Bagaimana cara menggunakan STDDEV_SAMP di BigQuery?
Gunakan sintaks berikut: STDDEV_SAMP(expression). Pastikan argumen yang dimasukkan sudah sesuai dengan tipe data yang diharapkan.
Apa nilai yang dikembalikan oleh fungsi STDDEV_SAMP?
Fungsi STDDEV_SAMP mengembalikan nilai bertipe FLOAT64. Pastikan tipe data hasil sudah sesuai dengan kebutuhan query atau formula kamu. Jika input mengandung nilai NULL, perilaku fungsi dapat berbeda — selalu periksa dokumentasi untuk memastikan hasilnya sesuai ekspektasi.
Apa saja parameter fungsi STDDEV_SAMP?
Fungsi ini memiliki 1 parameter wajib. Parameter yang digunakan: expression (numeric, wajib): A numeric column or expression for which to calculate the sample standard deviation.
Ngulik Langsung
Latihan Langsung →Sudah paham STDDEV_SAMP? Latih langsung di browser
Latihan interaktif, langsung di browser.