UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Graphset
    • Schema
    • Property
    • Constraints
    • Insert
    • Overwrite or Insert
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • All Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Table Functions
    • Null Functions
    • Type Conversion Functions
  • Operators
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
    • Cache
    • Overview
    • Managing HDC Graphs
    • HDC Graph Queries
    • Process
    • Job
    • Execution Plan
    • Alias
    • Filter
    • Values and Types
    • Data Flow in Queries
    • Comments
    • Reserved Words
  • Access Control
  1. Docs
  2. /
  3. UQL
  4. /
  5. Functions

Aggregate Functions

Overview

An aggregate function performs a calculation on a set of values and returns a single scalar value.

DISTINCT

All aggregate functions support the use of the set quantifier DISTINCT to eliminate duplicates before aggregation.

Null Values

Rows containing null values are ignored by all aggregate functions.

Example Graph

The following examples run against this graph:

avg()

Computes the average of a set of numeric values.

Syntaxavg(<values>)
ArgumentsNameTypeDescription
<values>NumericThe target values
Return TypeDOUBLE
UQL
find().nodes() as n
return avg(n.score)

Result:

avg(n.score)
7.33333333333333

collect()

Collects a set of values into a list.

Syntaxcollect(<values>)
ArgumentsNameTypeDescription
<values>AnyThe target values
Return TypeLIST
UQL
find().nodes() as n
return collect(n.title)

Result:

collect(n.title)
["Optimizing Queries","Efficient Graph Search","Path Patterns"]

count()

Returns the number of records in the input.

Syntaxcount(<values>)
ArgumentsNameTypeDescription
<values>AnyThe target values
Return TypeUINT
UQL
find().nodes() as n
return count(n)

Result:

count(n)
3
UQL
uncollect [1, "a", "2", "b3", null] as item
return count(item)

Result:

count(item)
4

count(DISTINCT)

You can include the set quantifier DISTINCT in count() to return the number of distinct records.

UQL
uncollect [1, 1, "a", "2", "b3", null] as item
return count(DISTINCT item)

Result:

count(DISTINCT item)
4

max()

Returns the maximum value in a set of values.

Syntaxmax(<values>)
ArgumentsNameTypeDescription
<values>AnyThe target values
Return TypeNumeric
UQL
find().nodes() as n
return max(n.score)

Result:

max(n.score)
9
UQL
uncollect [1, "a", "2.1", "b3"] as item
return max(item)

Result:

max(item)
2

min()

Returns the minimum value in a set of values.

Syntaxmin(<values>)
ArgumentsNameTypeDescription
<values>AnyThe target values
Return TypeNumeric
UQL
find().nodes() as n
return min(n.score)

Result:

min(n.score)
6
UQL
uncollect [1, "a", "2.1", "b3"] as item
return min(item)

Result:

min(item)
0

stddev_pop()

Computes the population standard deviation of a set of numeric values.

stddev_pop( x 1 , ...,  x n ) = 1 n ∑ i = 1 n ( x i − x — ) 2
Syntaxstddev_pop(<values>)
ArgumentsNameTypeDescription
<values>NumericThe target values
Return TypeNumeric
UQL
find().nodes() as n
return stddev_pop(n.score)

Result:

stddev_pop(n.score)
1.24721912892465

stddev_samp()

Computes the sample standard deviation of a set of numeric values.

stddev_samp( x 1 , ...,  x n ) = 1 n − 1 ∑ i = 1 n ( x i − x — ) 2
Syntaxstddev_samp(<values>)
ArgumentsNameTypeDescription
<values>NumericThe target values
Return TypeDOUBLE
UQL
find().nodes() as n
return stddev_samp(n.score)

Result:

stddev_samp(n.score)
1.52752523165195

sum()

Computes the sum of a set of values.

Syntaxsum(<values>)
ArgumentsNameTypeDescription
<values>NumericThe target values
Return TypeDOUBLE
UQL
find().nodes() as n
return sum(n.score)

Result:

sum(n.score)
22