Thuta Learning
ExercisesData & Databasesbeginner

Practice Set 1: SELECT & Filtering

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Practice Practice Set 1: SELECT & Filtering yourself
  • Practice the skills you've already learned to make them stick
  • Get comfortable finding mistakes, fixing them, and checking your own work

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

sql
-- 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 should see
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.

Easy traps

  • Mixing up % (percent sign) with _ (underscore) when writing a LIKE pattern
  • Forgetting to add DESC in ORDER BY and mistaking the default ASC (lowest to highest) order for 'sorting isn't working'

Now try it yourself

Change Task 1's condition to Price > 10000 AND Stock > 0 and try adding the AND operator — give yourself 5 minutes to try it.

You'll know it worked when: 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.

Practice Set 1: SELECT & Filtering | Thuta Learning