SQL Practice Tasks
Use these tasks with any sample ecommerce or HRM database. The goal is not memorizing syntax; the goal is thinking like a tester with data.
Beginner
- Find all active users created in the last 30 days.
- List the latest 20 failed orders.
- Find users with missing phone numbers.
Intermediate
- Join orders with customers and show customer name, order status, and total amount.
- Find customers who never placed an order.
- Count failed payments by customer and show only customers with 3 or more failures.
Advanced
- Validate that every paid order has exactly one successful payment.
- Find duplicate users by email after lowercasing and trimming spaces.
- Design test cases for rollback when payment succeeds but invoice creation fails.
Interview Questions
- What is the difference between WHERE and HAVING?
- What is the difference between INNER JOIN and LEFT JOIN?
- Why do indexes improve reads but slow down writes?
- What is a transaction, and why is rollback important?