MicrolearnENPTES

Learn SQL: 24 free interactive lessons

3 to 5 minute lessons with a real SQL database running in your browser. Write the query, press Run, see the answer. No installation, no account.

Do it in the browser: a real SQL tool, a short mission and instant feedback. No install. Optional certificate at the end of the course.

Open the course

Lessons

  1. Your first SELECTA database stores data in tables: rows are records, columns are fields. SELECT is how you ask a table for its data.
  2. Choosing columnsMost of the time you only need a few columns. List them after SELECT, separated by commas, in the order you want them.
  3. Filtering rows with WHEREWHERE keeps only the rows that meet a condition. Text values go between single quotes.
  4. Sorting and limitingORDER BY sorts the result; LIMIT keeps only the first rows. Together they answer 'top N' questions.
  5. AND, OR and NOTReal questions have several conditions. AND requires all of them, OR at least one, NOT inverts one.
  6. IN and BETWEENTwo shortcuts keep conditions short: IN checks a list of values, BETWEEN checks a range, ends included.
  7. Text patterns with LIKELIKE matches text against a pattern: % stands for any number of characters, _ for exactly one.
  8. Missing values: NULLNULL means 'unknown' or 'not filled in'. It is not zero and not empty text, and it needs its own operators.
  9. Counting rowsAggregate functions turn many rows into one value. COUNT is the simplest: how many rows match?
  10. SUM, AVG, MIN and MAXThe other everyday aggregates add up, average and find extremes. You can use several in the same SELECT.
  11. GROUP BYGROUP BY splits the rows into groups and runs the aggregate once per group, producing one row per group.
  12. Filtering groups with HAVINGWHERE filters rows before grouping; HAVING filters groups after the aggregates are computed.
  13. INNER JOINData is split across tables and linked by keys. A JOIN puts the pieces back together, matching rows where the keys are equal.
  14. LEFT JOINLEFT JOIN keeps every row of the left table, even without a match. Missing values on the right come back as NULL.
  15. Joining several tablesQuestions often cross three or four tables. Chain one JOIN per table, each with its own ON condition.
  16. A table joined to itselfSome tables point to themselves: each staff member has a manager who is also staff. Join the table twice with two aliases.
  17. SubqueriesA query inside another query. The inner query runs first and its result feeds the outer one.
  18. WITH: naming a stepA common table expression (CTE) gives a name to an intermediate result. Long queries become a sequence of readable steps.
  19. CASE: conditions inside SELECTCASE works like an if/else that produces a value for each row. Use it to label, bucket or translate data.
  20. Window functionsWindow functions compute across related rows without collapsing them. Ranking inside a group is the classic use.
  21. CREATE TABLETables are defined once with their columns and types. A primary key identifies each row; a foreign key points to another table.
  22. INSERTINSERT adds new rows. List the columns, then the values in the same order.
  23. UPDATE and DELETEUPDATE changes existing rows and DELETE removes them. Both use WHERE to choose which rows; forget it and every row is affected.
  24. Indexes and query plansAn index is a sorted lookup structure, like the index of a book. It makes searches on a column fast at the cost of some space and slower…