Categories:
Aggregate Functions (Linear Regression) , Window Functions

REGR_COUNT

Returns the number of non-null number pairs in a group.

Syntax

REGR_COUNT(y, x)

Usage Notes

  • DISTINCT is not supported for this function.

Examples

Show the number of pairs in each group, and the number of those pairs in which neither member is NULL.

create or replace table aggr(k int, v decimal(10,2), v2 decimal(10, 2));
insert into aggr values(1, 10, null);
insert into aggr values(2, 10, 11), (2, 20, 22), (2, 25,null), (2, 30, 35);

select k, count(*), regr_count(v, v2) from aggr group by k;

---+----------+-------------------+
 k | count(*) | regr_count(v, v2) |
---+----------+-------------------+
 1 |      1   |            0      |
 2 |      4   |            3      |
---+----------+-------------------+