Intermediate Code Reading #SQL #databases #data

🗃️ SQL Queries Explained

3 exercises — read SQL SELECT statements and choose the most accurate plain-English description. Covers JOINs, GROUP BY, aggregations, and window functions.

0 / 3 completed
Translating SQL to English
  • SELECT a, b FROM t → "retrieve / get / fetch [a] and [b] from [t]"
  • WHERE condition → "where [condition is true] / filtered to / only for"
  • LEFT JOIN t2 ON ... → "including all records from [t1], matched to [t2] where possible"
  • GROUP BY col → "grouped by / for each [col]"
  • HAVING COUNT = 0 → "that have no / where the count is zero"
  • ORDER BY col DESC → "sorted by [col], highest first / most recent first"
1 / 3
Read this SQL query. Which plain-English description is the most accurate?
SELECT u.name, u.email, COUNT(o.id) AS order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at >= '2024-01-01'
GROUP BY u.id, u.name, u.email
HAVING COUNT(o.id) = 0
ORDER BY u.created_at DESC;