Excel to SQL: formula equivalents

If you know Excel, you already know most of SQL. 27 spreadsheet functions and features, each with the formula, the SQL that does the same job, how it works, and the places where the results differ. Or skip the query and ask your question in plain English.

Lookups

Looking up a value from another table: VLOOKUP, XLOOKUP and INDEX/MATCH become joins.

Conditional calculations

SUMIF, COUNTIF and IF: calculations that only include rows meeting a condition.

Summaries and pivots

Pivot tables, sorting, filtering and ranking: the everyday ways of summarising a sheet.

Text functions

Cleaning and splitting text: TRIM, LEFT, TEXTJOIN and Text to Columns.

Dates and rounding

DATEDIF, EOMONTH, YEAR and ROUND, and how SQL handles dates and rounding differently.

For deeper query techniques see the SQL patterns library, or the glossary if a term is unfamiliar.