Let's think this through for a moment
This lesson is a practice set aimed at reinforcing basic-level queries — SELECT, WHERE, ORDER BY, LIKE, DISTINCT. There's no new theory here; you'll work hands-on with small tasks based on the Books and Customers tables from the Bookstore project. Writing queries yourself is how filter conditions, sort order, and pattern matching become second nature. Try writing the query for each task yourself before checking the sample answer in the code block.
Exercises
Task 1: From the Books table, use SELECT + WHERE to get the title and price of books priced above 10000. Task 2: From the Customers table, use SELECT DISTINCT to get a unique list of cities with no duplicates. Task 3: Use LIKE to find books whose Title contains the letters 'a' and 'e' (use '%a%' to find books with 'a' in the title). Task 4: Sort all the Books from highest price to lowest using ORDER BY DESC.
Code example
-- Task 1: Books over 10000 in price
SELECT Title, Price FROM Books WHERE Price > 10000;
-- Task 2: Unique cities
SELECT DISTINCT City FROM Customers;
-- Task 3: Titles containing 'a'
SELECT Title FROM Books WHERE Title LIKE '%a%';
-- Task 4: Books sorted by price, highest first
SELECT Title, Price FROM Books ORDER BY Price DESC;You'll get a small result table for each of the 4 tasks, and you'll be able to check for yourself that the filtering, distinct values, pattern matching, and sort order are all correct.5-minute try-it
Change Task 1's condition to Price > 10000 AND Stock > 0 and try adding the AND operator — give yourself 5 minutes to try it.
A quick word of caution
Read your condition back once before running any query — a wrong filter condition can throw off the result set without ever raising an error.