Select, filter, and sort
SELECT
id,
name,
email
FROM users
WHERE is_active = TRUE
ORDER BY name ASC
LIMIT 10;
Practice typing real code syntax, including brackets, punctuation, and indentation. Snippets are for typing practice only and are never executed.
SELECT
id,
name,
email
FROM users
WHERE is_active = TRUE
ORDER BY name ASC
LIMIT 10;
SELECT
customers.name,
COUNT(orders.id) AS order_count
FROM customers
LEFT JOIN orders
ON orders.customer_id = customers.id
GROUP BY customers.id, customers.name
ORDER BY order_count DESC;
WITH recent_orders AS (
SELECT customer_id, total
FROM orders
WHERE created_at >= '2026-01-01'
)
SELECT
customer_id,
SUM(total) AS total_spent
FROM recent_orders
GROUP BY customer_id
ORDER BY total_spent DESC;