SQL topics
Work through them in order. Each one builds on the last.
- Topic 1 路 4 questionsSELECTEvery SQL query that reads data starts with SELECT. You tell the database which columns you want, and FROM tells it which table to read.
- Topic 2 路 5 questionsWHEREWHERE keeps only the rows that match a condition. It comes after FROM, and the database checks the condition once for every row.
- Topic 3 路 4 questionsORDER BYWithout ORDER BY a database may return rows in any order. ORDER BY sorts the result by one or more columns, smallest first unless you add DESC.
- Topic 4 路 5 questionsGROUP BYAggregate functions like COUNT, SUM, AVG, MIN and MAX squash many rows into one number. GROUP BY splits the rows into groups first, so you get one number per group.
- Topic 5 路 5 questionsJOINsReal databases split data across tables. An orders table stores a customer_id rather than the customer's name. A JOIN matches rows from two tables using a condition, usually an id.
- Topic 6 路 4 questionsSubqueriesA subquery is a query in brackets that runs inside another query. It can produce a single value to compare against, or a list of values to check with IN.
- Topic 7 路 3 questionsWindow functionsA window function calculates across a set of rows related to the current row, but unlike GROUP BY it keeps every row. You add OVER (...) to say which rows count.