One task · six dialects · copy the one you need

The same SQL, in every dialect.

Running totals, top-N per group, removing duplicates with ROW_NUMBER, pivot and unpivot, upsert, reading JSON, recursive CTEs — each shown in MySQL, PostgreSQL, SQLite, BigQuery, Snowflake and DuckDB, with the gotchas that bite when you move between them.

19 recipes

Why this exists

You know the query. You don't remember which dialect spells it which way.

Every engine does the common things differently — upsert is ON CONFLICT in Postgres, ON DUPLICATE KEY UPDATE in MySQL, and MERGE in BigQuery and Snowflake; filtering a window function needs QUALIFY in some and a subquery in others. So you end up googling the same five patterns over and over. sqlindex.pages.dev puts each task on one page with the exact syntax per dialect, side by side, plus the traps (argument order, version requirements, NULL handling).

How it works

Find the task, copy your dialect's version

  1. Pick a recipe. Browse by topic in the full recipe list.
  2. Copy the block for your database (one-click copy on every snippet).
  3. Swap in your table and column names — the examples use plain placeholders.

FAQ

Frequently asked questions

Are these SQL recipes free?

Yes. Every recipe on sqlindex.pages.dev is free to read and copy, with no account, paywall, or sign-up. Some outbound links (for example to managed databases, data warehouses, or courses) may be affiliate links, which never change the price you pay.

Which databases are covered?

Each recipe shows the syntax for MySQL (8+), PostgreSQL, SQLite (3.25+), BigQuery, Snowflake, and DuckDB. Where a feature needs a specific version (window functions, QUALIFY, JSON_TABLE) the recipe says so.

Why does the same query differ between databases?

The SQL standard leaves a lot implementation-defined, and each engine grew its own functions — so aggregating strings is STRING_AGG in Postgres/BigQuery/DuckDB, GROUP_CONCAT in MySQL/SQLite, and LISTAGG in Snowflake. These recipes hand you the right one for your engine instead of making you translate.

What's QUALIFY, and why isn't it in every example?

QUALIFY filters the result of a window function inline (e.g. keep ROW_NUMBER() = 1), and it exists in BigQuery, Snowflake, and DuckDB. MySQL, PostgreSQL, and SQLite do not have it, so those versions wrap the window function in a subquery or CTE and filter outside. The recipes show both forms.

Is this the same as datesql?

They are companions with no overlap. datesql.pages.dev covers date and time across dialects (DATEDIFF, DATE_TRUNC, formatting, time zones). sqlindex covers everything else: window functions, grouping and pivots, upsert/MERGE, JSON, strings, and recursive CTEs.

Will the snippets run as-is?

They are minimal, working statements written with placeholder table and column names (orders, amount, customer_id…) that you swap for yours. Window functions need MySQL 8+, SQLite 3.25+, or any modern warehouse — version-sensitive parts are flagged in each recipe.