Skip to content

Query

The Query view gives you direct SQL access to your financial data via DuckDB.

Press Cmd+Enter to run a query. Click Schema to see available tables and columns.

SELECT tag, SUM(amount) as total
FROM (
SELECT unnest(tags) as tag, amount
FROM transactions
WHERE amount < 0
)
GROUP BY tag
ORDER BY total
SELECT
strftime('%Y-%m', transaction_date) as month,
SUM(amount) as total
FROM transactions
WHERE amount < 0
GROUP BY month
ORDER BY month DESC
LIMIT 12
SELECT transaction_date, description, amount
FROM transactions
WHERE CAST(tags AS VARCHAR) = '[]'
ORDER BY transaction_date DESC

For the complete database schema including all tables and columns, see Database Schema.

  • Use unnest(tags) to expand tag arrays for grouping
  • Use ILIKE '%term%' for case-insensitive text matching
  • Date filtering: transaction_date >= CURRENT_DATE - INTERVAL '30 days'

By default, only SELECT queries are allowed. Enable Write mode to run INSERT, UPDATE, or DELETE queries. Treeline will offer to create a backup first.

In the CLI, use tl query --allow-writes to enable write operations.

Write queries cannot be undone.