
A purpose-built expression language for aggregation-over-data calculations. Compiles deterministically to SQL — validated at parse time, not runtime. No raw SQL exposure. Strict PEMDAS enforcement.
The recursive-descent parser explicitly encodes operator precedence. This means SUM(a) + SUM(b) * 100 always evaluates as SUM(a) + (SUM(b) * 100), not (SUM(a) + SUM(b)) * 100.
| Precedence | Operators | Parser Method |
|---|---|---|
| 1 (highest) | ( ) parentheses | parsePrimary |
| 2 | unary - | parseUnary |
| 3 | * / % | parseMultiplicative |
| 4 (lowest) | + - | parseAdditive |
| Function | Description | Example |
|---|---|---|
SUM(column) | Sum of values | SUM(amount) |
AVG(column) | Arithmetic mean | AVG(amount) OVER(90 days) |
COUNT(*) | Row count | COUNT(*) WHERE(type = 'CREDIT') |
COUNT(DISTINCT col) | Distinct count | COUNT(DISTINCT payee) |
MIN(column) | Minimum value | MIN(amount) |
MAX(column) | Maximum value | MAX(amount) OVER(last_year) |
MEDIAN(column) | 50th percentile | MEDIAN(amount) |
STDEV(column) | Standard deviation | STDEV(amount) OVER(30 days) |
Day filters: weekends, weekdays, monday–sunday (and abbreviations mon–sun).
Calculate the income-to-expense ratio as a percentage over the last 30 days, rounded to 2 decimal places.
ROUND(
(SUM(amount) WHERE(type = 'income') OVER(30 days))
/
NULLIF(SUM(amount) WHERE(type = 'expense') OVER(30 days), 0)
* 100,
2
)Count all credit transactions in the current year.
COUNT(*) WHERE(type = 'CREDIT') PERIOD(YTD)Calculate the Gini coefficient for payment distribution across payees to detect concentration risk.
GINI(amount GROUP_BY(payee))Measure the percentage change in total revenue over the last 3 months.
CHANGE(amount, 3 months)Sum amounts of transactions exceeding $10,000 on weekends over the last 90 days.
SUM(amount) WHERE(amount > 10000 AND ON(weekends)) OVER(90 days)Calculate the standard deviation of monthly expenses to measure spending volatility.
STDEV(amount) WHERE(type = 'expense') OVER(last_year)Type a DSL expression below to see it parsed into an AST and compiled to SQL in real time. Click any example above to copy it, then paste it here.