EXISTS() GROUP BY ...

All functions > GROUP BY > EXISTS() GROUP BY ...

Returns TRUE if the group has at least one row (that passes the FILTER).

Syntax

EXISTS()
 [ FILTER (WHERE condition) ]
  [ GROUP BY feature [, feature ...] ]

Notes

  • Takes no argument; the condition goes in FILTER (WHERE ...), or in ON for RELATED ... ON and EXTEND ... ON
  • Returns FALSE for an empty group, never NULL: a known parent with no matching child is FALSE
  • A NULL parent key in RELATED stays NULL (an absent parent)
  • Rows whose condition is NULL do not match
  • EXISTS(condition) is accepted and FORMAT (FIX) rewrites it to EXISTS() FILTER (WHERE condition)
  • Inside RELATED, EXISTS() FILTER (WHERE p) has the value of BOOL_OR(p)

See also

Examples

FeatureQL
-- A matching row exists
-- No matching row: FALSE, not NULL
RETURN
    f1 := ZIP(ARRAY(1, 2, 3) AS value).TRANSFORM(
        RETURN EXISTS() FILTER (WHERE value > 2)
    ).UNWRAP_ONE(),
    f2 := ZIP(ARRAY(1, 2, 3) AS value).TRANSFORM(
        RETURN EXISTS() FILTER (WHERE value > 5)
    ).UNWRAP_ONE()
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse