All guides

Learning SQL from scratch in 2026: a practical guide

SQL is the language used to query databases, and it is one of the best effort-to-value skills that exist: quick to learn and useful in almost every digital job — development, data analysis, marketing, operations. The good news: there is nothing to install — every query in this guide runs right on the page with "Try it".

The mental model: tables as spreadsheets

A database is made of tables. A table is like an Excel sheet: rows (the data) and columns (the fields). Every example below runs on this impiegati (employees) table:

idnome (name)reparto (dept)stipendio (salary)
1AnnaVendite2500
2LucaIT3200
3MarcoIT2800
4SaraVendite2700
5ElenaHR2400

SQL does not make you "scroll" through data row by row: you describe what you want and it returns it. It is a different, freeing way of thinking.

Reading data: SELECT

The most basic query: take everything.

SELECT * FROM impiegati;

SELECT picks the columns (* = all), FROM says which table. Almost everything in SQL is a variation of this skeleton. Usually you don't want everything though — ask only for the columns you need:

SELECT nome, stipendio FROM impiegati;

Filtering rows: WHERE

This is where SQL gets powerful. WHERE keeps only the rows that match a condition:

SELECT nome, stipendio
FROM impiegati
WHERE reparto = 'IT';

Note the single quotes around 'IT': that is how strings are written in SQL. Try changing 'IT' to 'Vendite' and run.

Sorting: ORDER BY

SELECT nome, stipendio
FROM impiegati
ORDER BY stipendio DESC;

ORDER BY sorts the result; DESC = largest to smallest (without it, ascending). Handy for rankings, "most recent", "best selling".

Doing the math: aggregate functions

Often you don't want the rows, but a summary number: how many, the average, the total.

SELECT COUNT(*), AVG(stipendio)
FROM impiegati;

COUNT, AVG, SUM, MIN, MAX squeeze many rows into a single value. They are the heart of every report.

The level-up: GROUP BY

What if you wanted the average per department instead of overall? GROUP BY splits rows into groups and applies the aggregation to each:

SELECT reparto, AVG(stipendio) AS media
FROM impiegati
GROUP BY reparto
ORDER BY media DESC;

When this query feels obvious, you understand 70% of the SQL actually used at work: read, filter, sort, aggregate, group.

A realistic study plan

Don't memorise syntax: write queries, make mistakes, look at what comes out. That is how it sticks.

Where to go from here

The SQL path starts exactly here and goes all the way to JOINs, subqueries, window functions, indexes and transactions: 13 chapters and 100+ exercises, all runnable in the browser like the ones above. The first chapters are free. Just want to try a few queries? The playground has open SQL, no sign-up.

Learn by doing, not just reading

Zero-to-advanced paths with exercises you write and run in the browser. The first chapters are free.

Learning SQL from scratch in 2026: a practical guide — LevelUpCode