Query building guides
Learn the building blocks after running your first query.
New to Quarry? Run the quickstart or connect an existing project. For a complete query you can adapt, start with recipes.
Define and reuse queries
- Generate schema types from your ClickHouse database.
- Compose application queries with optional filters, SQL fragments, unions, and windows.
- Use expressions and functions for dates, casts, conditionals, and aggregates.
- Join tables while preserving source aliases and result types.
- Reuse CTEs and subqueries to build queries in stages.
Work with ClickHouse data
- Arrays and ARRAY JOIN: expand array elements into rows.
- Aggregations: group results, filter aggregates, and request totals.
- Inserts: write batches and transform data with INSERT SELECT.
Run and troubleshoot
- Execution reference: buffered rows, first-row helpers, totals, and streams.
- Debugging: inspect SQL, parameters, and inferred types.
- Performance: query execution and TypeScript performance.
- Versions and upgrading: match examples to your installed package.