Programming and data

Learn SQL: what to know and where to start

SQL is the standard language for asking questions of data stored in relational databases. Analysts, developers and data engineers use it, and it is one of the most requested data skills.

Outcomes

What you will be able to do with SQL

  • Query a table with SELECT, WHERE and ORDER BY
  • Group and summarise data
  • Join several tables
  • Use subqueries and CASE expressions
  • Speed up a slow query

Learning path

How to learn SQL, in order

  1. Beginner

    Query one table

    Learn SELECT, WHERE, ORDER BY, GROUP BY and aggregate functions. You are ready when you can answer simple questions from a single table.

  2. Intermediate

    Combine and shape data

    Practise joins, subqueries, CASE expressions, dates and strings. You are ready when you can answer questions that need several tables and check the result is right.

  3. Advanced

    Write advanced and efficient queries

    Learn window functions, CTEs, indexes and reading query plans. You are ready when you can speed up a slow query and explain the change.

Keep going

Where to go next

The first is the natural next step from this page. The rest follow what you have been reading.

FAQs

SQL: common questions

What is SQL?

SQL is the language used to create, fill and query tables in a relational database. The PostgreSQL tutorial introduces it in a chapter on the SQL language that covers creating tables, adding rows, querying, joins, aggregate functions, updates and deletions.

Do I need programming experience to learn SQL?

Not necessarily. The PostgreSQL tutorial says it assumes only some general knowledge about how to use computers and that no particular Unix or programming experience is required.

What do I learn after the basics?

The PostgreSQL tutorial's advanced section covers views, foreign keys, transactions and window functions. These match the intermediate and advanced stages of the learning path on this page.

Is SQL the same in every database?

Mostly, but not entirely. The PostgreSQL documentation notes that some of its language features are extensions to the standard, so check which database a course teaches.

Is one tutorial enough to learn SQL?

No. The PostgreSQL tutorial says it only gives an introduction and is in no way a complete tutorial on SQL. Practise on your own data after any course.