Calculated field
{ FIXED [Customer] : MIN([Date]) }
Sample data
| Region | Team | Customer | Revenue | Seats | Date |
|---|---|---|---|---|---|
| North | Cedar | Aster | 120 | 4 | 2026-01-05 |
| North | Cedar | Aster | 80 | 2 | 2026-02-05 |
| North | Cedar | Birch | 300 | 6 | 2026-01-12 |
| North | Pine | Clover | 90 | 3 | 2026-02-14 |
| South | Elm | Dahlia | 200 | 5 | 2026-01-08 |
| South | Elm | Dahlia | 100 | 2 | 2026-02-08 |
| South | Ash | Fern | 75 | 3 | 2026-01-20 |
| South | Ash | Fern | 25 | 1 | 2026-02-20 |
The same calculation as SQL
SELECT "Customer", MIN("Date") AS result FROM input GROUP BY "Customer" ORDER BY "Customer"Runs the example above.
SELECT "Customer", MIN("Date") AS result FROM input GROUP BY "Customer" ORDER BY "Customer"Written for this dialect; not run here.
SELECT `Customer`, MIN(`Date`) AS result FROM input GROUP BY `Customer` ORDER BY `Customer`
Written for this dialect; not run here.
Result
| Customer | result |
|---|---|
| Aster | 2026-01-05 |
| Birch | 2026-01-12 |
| Clover | 2026-02-14 |
| Dahlia | 2026-01-08 |
| Fern | 2026-01-20 |
Same rows from the calculation and from the SQL in DuckDB.
Where a naive translation goes wrong
- MAX returns the most recent invoice; MIN returns the first invoice for customers with several dates.
Naive SQL
SELECT "Customer", MAX("Date") AS result FROM input GROUP BY "Customer" ORDER BY "Customer"Customer result Aster 2026-02-05 Birch 2026-01-12 Clover 2026-02-14 Dahlia 2026-02-08 Fern 2026-02-20 Matches the calculation
SELECT "Customer", MIN("Date") AS result FROM input GROUP BY "Customer" ORDER BY "Customer"Customer result Aster 2026-01-05 Birch 2026-01-12 Clover 2026-02-14 Dahlia 2026-01-08 Fern 2026-01-20
Signature
{ FIXED [Customer] : MIN([Date]) }