COUNT_IF() OVER ...

All functions > WINDOW FUNCTION > COUNT_IF() OVER ...

Returns the count of rows where the condition is true in the window frame.

Syntax

COUNT_IF(expr) OVER ([PARTITION BY expr [, ...]] [ORDER BY sort_item [, ...]] [ROWS|RANGE|GROUPS frame])

Notes

  • Counts rows where the boolean expression evaluates to true
  • NULL values are treated as false
  • Always returns BIGINT type
  • Equivalent to COUNT(*) FILTER (WHERE condition) in standard SQL

See also

Examples

FeatureQL
SELECT
    f1 := ZIP(ARRAY[10, 20, 30] AS id, ARRAY[10, 20, 30] AS v).TRANSFORM(SELECT COUNT_IF(v > 15) OVER (ORDER BY id ASC)).UNWRAP() -- Rows with v > 15 so far (0, then 1, …), not id
;
Result
f1 ARRAY
[0, 1, 2]

Last update at: 2026/05/26 17:22:09