03

Data Analyst · Step 3 of 8 · 12 min

SQL basics

You can write queries that filter, group and join tables, and practise for free online.

Why SQL beats copy-paste

Company data lives in databases, often far too large for a spreadsheet. SQL (Structured Query Language) is how you ask a database for exactly the rows and totals you need. It is the most requested skill in analyst job ads.

A query is also a written record. Anyone can rerun it next month and get the same logic, which is much safer than a chain of manual copy, paste and filter steps nobody can repeat.

SELECT, FROM, WHERE

The basic shape: SELECT the columns you want, FROM a table, WHERE a condition is true. For example: SELECT order_id, amount FROM orders WHERE order_date >= '2026-01-01'. Add ORDER BY amount DESC to sort, and LIMIT 10 to see the top ten.

Start every new table with SELECT * FROM table LIMIT 10 to see what the columns actually contain before you write anything clever.

GROUP BY: totals by category

GROUP BY is the SQL version of a pivot table. SELECT region, COUNT(*) AS orders, SUM(amount) AS revenue FROM orders GROUP BY region gives one row per region.

Use WHERE to filter rows before grouping and HAVING to filter the groups afterwards, for example HAVING SUM(amount) > 10000.

JOIN: combining tables

Databases split data across tables: orders in one, customers in another, linked by an ID. JOIN brings them together: FROM orders o JOIN customers c ON o.customer_id = c.id.

An inner JOIN keeps only rows that match on both sides. A LEFT JOIN keeps every row from the first table, with blanks where there is no match. Compare row counts before and after any join; a sudden jump usually means duplicate keys are multiplying rows.

Where to practise for free

SQLBolt has short interactive lessons in the browser. Mode’s SQL tutorial walks through real-looking business data. DB Fiddle lets you create small tables and test queries. Google BigQuery has a free sandbox with public datasets, no credit card needed.

Dialects differ slightly (date functions especially), but SELECT, WHERE, GROUP BY and JOIN work almost everywhere.

Try it

Your first ten queries

  1. 1.Open SQLBolt (sqlbolt.com) and complete the first lessons up to simple JOINs.
  2. 2.Write one query of your own that uses GROUP BY.
  3. 3.Ask a chatbot to explain your query line by line using the prompt below.
I am learning SQL. Here is my query: [PASTE QUERY]. Explain what each line does in plain words, tell me what the result will look like, and point out one mistake a beginner might make with it.
After joining orders to customers, you have far more rows than orders. What should you suspect?

Check yourself

After joining orders to customers, you have far more rows than orders. What should you suspect?