> ## Documentation Index
> Fetch the complete documentation index at: https://docs.synehq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

> Ready-to-run SQL for cross-database analytics

## Compare users and orders (Postgres + MySQL)

```sql theme={"system"}
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

```sql theme={"system"}
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

```sql theme={"system"}
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;
```

<Info>
  DuckDB can read CSV/JSON/Parquet directly via HTTP/S3—handy for temporary joins without loading data.
</Info>

## Materialize a subset into DuckDB

```sql theme={"system"}
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;
```

<Note>
  Materialization is optional; most queries can run fully federated without persisting.
</Note>
