SQL Examples

SQL examples for local file analysis

These starter queries work well right after importing CSV, JSON, or Parquet files into SQL for Files. Replace table and column names with your own schema.

Preview and profile imported tables

Find missing values and duplicate keys

Join two imported files

Create chart-ready aggregate result sets

How it works

  1. Add your file and note the generated table name in the Database sidebar.
  2. Copy an example and replace my_table and the column names with your own.
  3. Run it, then adjust filters and groupings until the result answers your question.

Example queries

Profile every column

SUMMARIZE my_table;

Find missing values

SELECT COUNT(*) AS missing_rows
FROM my_table
WHERE important_column IS NULL;

Find duplicate keys

SELECT id, COUNT(*) AS copies
FROM my_table
GROUP BY id
HAVING COUNT(*) > 1
ORDER BY copies DESC;

Create a chart-ready result

SELECT category, COUNT(*) AS rows, AVG(amount) AS average_amount
FROM my_table
GROUP BY category
ORDER BY rows DESC;

Frequently asked questions

Which SQL dialect do these examples use?

DuckDB SQL. It follows standard SQL closely and adds conveniences such as SUMMARIZE for quick column profiles.