Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

SQL
SQL
0/12 completed
Beginner
What is a database?SELECT: reading dataFiltering with WHERESorting and limiting results
Intermediate
Aggregates and GROUP BYJOINs: combining tablesINSERT, UPDATE and DELETECreating tables and constraints
Advanced
Subqueries and CTEsWindow functions
Pro
Indexes and transactionsDatabase design and normalization
Tracks / SQL / Beginner

SELECT: reading data

SELECT is the most-used SQL command. It reads data and returns a result table.

Choosing columns

* means "all columns". In real projects, list the columns you need: the query is clearer and faster.

SQL · editable

SQL keywords aren't case-sensitive (select works too), but writing them in UPPERCASE is a common convention that makes queries easier to read. The ; ends a statement.

Calculated columns and aliases

You can compute new values. AS gives a column a friendly name (an alias).

SQL · editable

Text functions

SQL · editable

-- starts a comment in SQL.

Function names vary a little between databases. For example, PostgreSQL also has CONCAT(), and MySQL uses CONCAT() instead of ||. The concepts are identical.

Removing duplicates with DISTINCT

SQL · editable
SQL · editable

CASE: if/else in SQL

SQL · editable

Practice

  1. Show every product's name, category and its price in cents (price * 100) as price_cents.
  2. Show each customer's name and the domain of their email. Hint: SUBSTR(email, INSTR(email, '@') + 1).
SQL · editable
✎ Check your understanding

1.What does SELECT DISTINCT city FROM customers return?

2.What is AS used for?

← What is a database?