Skip to main content

Compare users and orders (Postgres + MySQL)

SELECT u.id, u.name, SUM(o.amount) AS revenue
FROM postgres_db.public.users u
JOIN mysql_db.sales.orders o ON u.id = o.user_id
GROUP BY u.id, u.name
ORDER BY revenue DESC
LIMIT 10;

Time-windowed metrics

SELECT DATE_TRUNC('month', o.created_at) AS month, SUM(o.amount) AS revenue
FROM mysql_db.sales.orders o
GROUP BY month
ORDER BY month;

Bring in a CSV alongside a database

SELECT u.email, c.last_login
FROM postgres_db.public.users u
JOIN read_csv_auto('https://example.com/logins.csv') c
  ON u.email = c.email;
DuckDB can read CSV/JSON/Parquet directly via HTTP/S3—handy for temporary joins without loading data.

Materialize a subset into DuckDB

CREATE TABLE top_customers AS
SELECT u.id, u.name, SUM(o.amount) AS revenue
FROM postgres_db.public.users u
JOIN mysql_db.sales.orders o ON u.id = o.user_id
GROUP BY u.id, u.name
ORDER BY revenue DESC
LIMIT 100;
Materialization is optional; most queries can run fully federated without persisting.
I