aggregations
rest
Aggregations
Use ?select= with aggregate functions for instant analytics — no separate endpoints needed.
Functions
| Function | Example |
|---|---|
count() | ?select=count() |
sum(col) | ?select=amount.sum() |
avg(col) | ?select=amount.avg() |
min(col) | ?select=amount.min() |
max(col) | ?select=amount.max() |
Examples
Count all records
GET /api/v1/payment?select=count()
{ "data": [{ "count": 14596 }] }
Sum payments by customer
GET /api/v1/payment?select=customer_id,amount.sum()
{
"data": [
{ "customer_id": 1, "sum": 118.68 },
{ "customer_id": 2, "sum": 128.73 }
]
}
Multiple aggregates
GET /api/v1/payment?select=amount.sum(),amount.avg(),amount.max(),count()
{
"data": [{
"sum": 67416.51,
"avg": 4.20,
"max": 11.99,
"count": 16049
}]
}
Group by with filter
GET /api/v1/rental?select=staff_id,count()&return_date=not.is.null
{
"data": [
{ "staff_id": 1, "count": 8040 },
{ "staff_id": 2, "count": 7290 }
]
}
Top spenders
GET /api/v1/payment?select=customer_id,amount.sum()&orderBy=sum&orderDirection=desc&limit=10