Actions25
- Database Actions
- Memory Actions
- Query Actions
- Query Builder Actions
- Table Actions
- Table Management Actions
Query Builder → Aggregate Query
AI-generatedSummary
Build and execute an aggregate query on a Cloudflare D1 table, optionally grouping and filtering rows.
Inputs
- databaseId (required) — The unique identifier of your Cloudflare D1 database.
- builderTable (required) — The table to query.
- whereConditions — Conditions to filter rows before aggregation.
- aggregateFunction — Aggregate function to apply (e.g., AVG, COUNT, MAX, MIN, SUM).
- aggregateColumn — Column to aggregate (leave empty for COUNT(*)).
- groupBy — Columns to group by.
Output shape
array of aggregated rows
Each row contains the grouping columns (if any) and the result of the selected aggregate function; may include additional metadata such as row count.
Examples
Example 1: Count all rows in the users table.
databaseId = $databaseId, builderTable = 'users', aggregateFunction = 'COUNT', aggregateColumn left empty, groupBy empty
Example 2: Sum of price per category where price is greater than 100.
databaseId = 'db123', builderTable = 'orders', aggregateFunction = 'SUM', aggregateColumn = 'price', groupBy = ['category'], whereConditions = [{field:'price',operator:'>',value:'100'}]