The count query expression derives a single integer—the number of rows returned by a nested query specification.
Syntax<count query expression> ::= "COUNT {" <query> "}"
Details
<query> is executed as a complete query, and COUNT { ... } returns the number of rows it produces. The body must therefore end with a RETURN.RETURN should project the matched rows (e.g. RETURN c), not an aggregate. A body like RETURN count(c) produces a single row, so COUNT { ... } would always return 1.NOTENon-standard extension.
COUNT { ... }is not part of the GQL standard (ISO/IEC 39075). GQLDB accepts it for convenience, but queries using it run with an advisory warning. Prefer the standard Value Query Expression in new queries.

GQLINSERT (p1:Paper {_id:'P1', title:'Efficient Graph Search', score:6}), (p2:Paper {_id:'P2', title:'Optimizing Queries', score:9}), (p3:Paper {_id:'P3', title:'Path Patterns', score:7}), (p1)-[:Cites]->(p2), (p2)-[:Cites]->(p3)
Count the papers each paper cites:
GQLMATCH (p:Paper) LET citations = COUNT { MATCH (p)-[:Cites]->(c:Paper) RETURN c } RETURN p.title, citations
Result:
| p.title | citations |
|---|---|
| Efficient Graph Search | 1 |
| Optimizing Queries | 1 |
| Path Patterns | 0 |
The standard equivalent, which does not emit a warning:
GQLMATCH (p:Paper) LET citations = VALUE { MATCH (p)-[:Cites]->(c:Paper) RETURN count(c) } RETURN p.title, citations