Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.32 KB

File metadata and controls

48 lines (34 loc) · 1.32 KB
description
Returns the sample covariance for non-NULL pairs across all input values.

COVAR_SAMP

Syntax

COVAR_SAMP(expression1 numeric, expression2 numeric) → double

  • expression1: An expression that evaluates to a numeric type. This parameter is the dependent value.
  • expression2: An expression that evaluates to a numeric type. This parameter is the independent value.

Examples

{% code title="Aggregate function example" %}

SELECT COVAR_SAMP(transaction_count, gas_used)
FROM eth.recent_blocks

-- 31.70536780565699

{% endcode %}

{% code title="Aggregate function example using optional DISTINCT clause" %}

SELECT COVAR_SAMP(DISTINCT transaction_count, gas_used)
FROM eth.recent_blocks

-- 31.7053678056971

{% endcode %}

{% code title="Window function example" %}

SELECT COVAR_SAMP(transaction_count, gas_used)
  OVER (PARTITION BY transaction_count)
FROM eth.recent_blocks

-- 2.442515362986122e-15

{% endcode %}

Usage Notes

This function supports the use of ALL and DISTINCT:

SELECT COVAR_SAMP( [ { ALL | DISTINCT } ] expression1, expression2)