regr_count
Counts input pairs for which both numeric arguments are non-NULL. Use it to find the number of observations admitted by the covariance, correlation and regression aggregates.
Syntax
text
regr_count(y, x)Arguments
y— The dependent numeric variable.x— The independent numeric variable.
A row with either argument NULL is excluded. Nonfinite numeric pairs are counted.
Returned value
A nonnegative INTEGER pair count. Empty input, or input with no complete pairs, returns 0.
Examples
Counting complete observations
sql
CREATE TABLE measurements (hour INTEGER, reading INTEGER);
INSERT INTO measurements VALUES (1, 3), (2, 5), (3, NULL), (NULL, 9);sql
SELECT count(*) AS rows,
count(hour) AS hours,
count(reading) AS readings,
regr_count(reading, hour) AS complete_pairs
FROM measurements
FORMAT csv;text
4,3,3,2No complete observations
sql
CREATE TABLE incomplete_measurements (hour INTEGER, reading INTEGER);
INSERT INTO incomplete_measurements VALUES (1, NULL), (NULL, 5);sql
SELECT regr_count(reading, hour)
FROM incomplete_measurements
FORMAT csv;text
0See regr_slope, covar_pop and corr for calculations over the admitted pairs.