SQL Exercises

Fill in the blanks to test your knowledge.

1

Select all columns from the users table

* FROM users;
2

Add a WHERE clause to filter by id

SELECT * FROM users id = 1;
3

Sort results by name ascending

SELECT * FROM products name ASC;
4

Limit results to 10 rows

SELECT * FROM posts ORDER BY date DESC 10;
5

Insert a new user record

INTO users (name, email) VALUES ("Alice", "alice@example.com");
6

Update a user's email

users SET email = "new@example.com" WHERE id = 1;
7

Delete a record by id

FROM users WHERE id = 42;
8

Count all rows in the orders table

SELECT (*) AS total FROM orders;
9

Join users with orders table

SELECT * FROM orders JOIN users ON orders.user_id = users.id;
10

Group results by category

SELECT category, COUNT(*) FROM products category;