Build analytical reports with SQL
Coordinator DB supports analytical query tasks through ordinary SQL: filters select the input, aggregates summarize groups and window functions compare rows without collapsing them all into one total. Start with a precise report question and verify its expected rows on a small dataset.
SELECT day, count(*) AS orders, sum(amount) AS revenue
FROM orders
WHERE day >= '2025-01-01' AND day < '2025-02-01'
GROUP BY day
ORDER BY day;This query reports only dates present in the source. If empty dates must appear, generate or supply a calendar relation and join the totals to it. Choose a decimal declaration for money when exact decimal arithmetic is required, rather than inferring precision from display formatting.
Add joins carefully: a one-to-many relationship can multiply rows before aggregation. For ranking or running comparisons, use the documented window functions with an explicit ordering. An ordinary view can name a reusable report query but does not store its result.
Measure representative input sizes and output needs rather than promising performance from the word analytical alone. Inspect plans and query counters when a report becomes expensive.
See aggregates, window functions, views and query measurements.