Start with the question, not the syntax.
Today's skill is simple: identify the table you need, choose the columns you want, filter the right rows, and sort the result.
Think in tables
A table is a collection of rows. A row is one record. A column is one attribute. SQL asks the database to produce a result set from those rows.
Four building blocks
SELECT name FROM customers WHERE country = 'India' ORDER BY name;
Read it like a sentence.
- FROM — start with this table.
- WHERE — keep only matching rows.
- SELECT — return these columns.
- ORDER BY — choose the output order.
Find the largest orders.
SELECT order_id, amount FROM orders ORDER BY amount DESC LIMIT 3;
First understand the question. Then identify the columns. Then write the smallest query that answers it.
Without looking at the example: How would you find the names of customers from India, sorted alphabetically?
SELECT name FROM customers WHERE country = 'India' ORDER BY name;Now go to Practice and write it yourself without copying.
Do one final question without help.
Write a query that returns order_id and amount for orders above 2000, highest amount first.
Write. Run. Check. Try again.
Hints are available, but use them only after an honest attempt. The engine runs in your browser; no account is required.
customers · orders · employeesSQL engine
Loading…
Small steps. Keep going.
Progress is saved on this device. No sign-in is needed.
Your first review comes after mastery.
Complete the Day 0 mastery question. Then revisit the idea after a short gap and solve a fresh question without looking at the lesson.