An ordered set of instructions. It reads input, follows rules, and produces output.
Workspace
SQL
data querying product analytics and databases
Definition first
What SQL means
SQL is a programming language for writing exact instructions, often used for data querying product analytics and databases. Start with one mental model: input goes through steps and becomes output.
query.sqlRun psql -f query.sqlHabit Start with SELECT columns then add WHERE then JOIN then aggregateA value is data. A variable is the name you use to hold and reuse that data.
A named piece of work. It takes input, does one job, and can return a result.
PostgreSQL compatible SQL is the place that actually runs code from query.sql.
First readable code
Select
columns table rowsSELECT name, score FROM users;
Output name score rowsLanguage lineage
SQL family tree
See where SQL comes from, which languages feel close, and what to learn next.
Zero base path
Question bank
Search before practice
Pick a stage or search across the open programming bank. Jump straight to the matching drill.
SQL practice 1
SQL question 1. Choose the statement that matches select columns.
SQL practice 2
SQL question 2. Choose the statement that matches where filter.
SQL practice 3
SQL question 3. Choose the statement that matches count aggregate.
SQL practice 4
SQL question 4. Choose the statement that matches join tables.
SQL practice 5
SQL question 5. Choose the statement that matches select columns.
SQL practice 6
SQL question 6. Choose the statement that matches where filter.
SQL practice 7
SQL question 7. Choose the statement that matches count aggregate.
SQL practice 8
SQL question 8. Choose the statement that matches join tables.
SQL practice 9
SQL question 9. Choose the statement that matches select columns.
SQL practice 10
SQL question 10. Choose the statement that matches where filter.
SQL practice 11
SQL question 11. Choose the statement that matches count aggregate.
SQL practice 12
SQL question 12. Choose the statement that matches join tables.
SQL practice 13
SQL question 13. Choose the statement that matches select columns.
SQL practice 14
SQL question 14. Choose the statement that matches where filter.
SQL practice 15
SQL question 15. Choose the statement that matches count aggregate.
SQL practice 16
SQL question 16. Choose the statement that matches join tables.
SQL practice 17
SQL question 17. Choose the statement that matches select columns.
SQL practice 18
SQL question 18. Choose the statement that matches where filter.
Multiple choice
SQL practice 1
SQL question 1. Choose the statement that matches select columns.
SELECT name FROM users;
Reference
Patterns for query.sql
psql -f query.sqlcolumns table rows
Select
SELECT name, score FROM users;
- Select only needed columns
- Read from one table first
- Add limits while exploring
where order limit
Filter
SELECT name FROM users WHERE score >= 60;
- WHERE filters rows
- ORDER BY sorts
- LIMIT protects exploration
count sum avg group by
Group
SELECT role, COUNT(*) FROM users GROUP BY role;
- Aggregate after filtering
- Group by non aggregate columns
- Name metrics clearly