Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Functions Reference


Aggregate Functions

These functions operate on groups of rows in SELECT queries with GROUP BY.

FunctionDescriptionExample
COUNT(*)Count all rowsSELECT COUNT(*) FROM users
COUNT(column)Count non-null valuesSELECT COUNT(name) FROM users
SUM(column)Sum numeric valuesSELECT SUM(total) FROM orders
AVG(column)Average numeric valuesSELECT AVG(age) FROM users
MIN(column)Minimum valueSELECT MIN(created) FROM orders
MAX(column)Maximum valueSELECT MAX(total) FROM orders
SELECT team, COUNT(*) AS headcount, AVG(age) AS avg_age
FROM employees
GROUP BY team
HAVING COUNT(*) > 5
ORDER BY headcount DESC

Graph Algorithm Functions

These are invoked as top-level commands, not as SQL functions. See the Query Language Reference for full syntax.

AlgorithmDescriptionReturns
PAGERANKLink analysis rankingNode scores (0.0-1.0)
BETWEENNESSBridge node importanceNode scores
CLOSENESSAverage distance to all nodesNode scores
EIGENVECTORInfluence-based rankingNode scores
LOUVAINCommunity detectionCommunity assignments
LABEL_PROPAGATIONCommunity detectionCommunity assignments

Graph Aggregate Functions

Used with the GRAPH AGGREGATE command on node/edge properties.

FunctionDescription
COUNTCount nodes/edges matching criteria
SUMSum of property values
AVGAverage of property values
MINMinimum property value
MAXMaximum property value
GRAPH AGGREGATE COUNT NODES person
GRAPH AGGREGATE AVG NODE age person WHERE age > 20
GRAPH AGGREGATE SUM EDGE weight collaborates

Distance Metrics

Used with SIMILAR and EMBED commands for vector similarity search.

MetricKeywordRangeBest For
Cosine similarityCOSINE-1.0 to 1.0Text embeddings, normalized vectors
Euclidean distanceEUCLIDEAN0.0 to infinitySpatial data, image features
Dot productDOT_PRODUCT-infinity to infinityPre-normalized vectors, recommendation
SIMILAR [0.1, 0.2, 0.3] LIMIT 10 METRIC COSINE
SIMILAR 'doc1' LIMIT 5 METRIC EUCLIDEAN

The default metric is COSINE when not specified.


Expression Operators

Arithmetic

OperatorDescription
+Addition
-Subtraction
*Multiplication
/Division
%Modulo

Comparison

OperatorDescription
=Equal
!= or <>Not equal
<Less than
<=Less than or equal
>Greater than
>=Greater than or equal

Logical

OperatorDescription
ANDLogical AND
ORLogical OR
NOTLogical NOT

Special Predicates

PredicateDescriptionExample
IS NULLTest for nullWHERE name IS NULL
IS NOT NULLTest for non-nullWHERE name IS NOT NULL
IN (list)Set membershipWHERE id IN (1, 2, 3)
NOT IN (list)Set non-membershipWHERE id NOT IN (1, 2)
BETWEEN a AND bRange checkWHERE age BETWEEN 18 AND 65
LIKE patternPattern matchingWHERE name LIKE 'A%'
NOT LIKE patternNegative patternWHERE name NOT LIKE '%test%'
EXISTS (subquery)Subquery existenceWHERE EXISTS (SELECT ...)

CASE Expression

CASE
    WHEN condition THEN result
    [WHEN condition THEN result ...]
    [ELSE default]
END
SELECT name,
    CASE
        WHEN age < 18 THEN 'minor'
        WHEN age < 65 THEN 'adult'
        ELSE 'senior'
    END AS category
FROM users

CAST

CAST(expression AS type)
SELECT CAST(age AS FLOAT) / 10 AS decade FROM users