EdgeQL Tutorial

Aggregates

Subtopics

One of the simple, but powerful built-in functions is "count". It's a function that takes a set of anything as its input and returns the number of elements in that set. Try counting all Media objects:

Input
Run
Output
Press the 'Run' button to evaluate the input

Since all values in EdgeDB can be compared to other values of the same type you can find a "minimum" and a "maximum" value by using min and max, respectively:

Input
Run
Output
Press the 'Run' button to evaluate the input
Input
Run
Output
Press the 'Run' button to evaluate the input

Another pair of useful functions is array_agg and array_unpack which convert a set to an array and vice versa, respectively. Try them out:

Input
Run
Output
Press the 'Run' button to evaluate the input