SQL Beginner Challenge 2: Filter Rows with WHERE

Difficulty: Beginner
Estimated time: 5–10 minutes
SQL concepts: WHERE, filtering rows, conditions
Goal: Return only the rows that matter.

The Scenario

You’re still working with the products table from Challenge #1.

This time, the product manager only wants to see products that belong to the Accessories category.

Instead of filtering data later in Excel or a dashboard, you’re asked to do this directly in SQL.

Database Table

products

column_nametypedescription
product_idINTEGERUnique product ID
nameTEXTProduct name
categoryTEXTProduct category
priceDECIMALProduct price
stock_qtyINTEGERUnits in stock
created_atTIMESTAMPWhen the product was created

Sample Data (for context)

product_idnamecategorypricestock_qty
101Wireless MouseAccessories24.99120
102Mechanical KeyboardAccessories89.0045
10327-inch MonitorDisplays229.9918
104USB-C HubAccessories34.5070
105Laptop StandWorkspace39.9932

Your Task

Write a SQL query that returns only products in the Accessories category, showing:

  • name
  • price
  • category

Expected Output

namepricecategory
Wireless Mouse24.99Accessories
Mechanical Keyboard89.00Accessories
USB-C Hub34.50Accessories

Constraints

  • Do not use SELECT *
  • Filter rows using WHERE
  • Match the category name exactly (Accessories)
  • Column order must be: name, price, category

Hint (Optional)

The WHERE clause is used after FROM to filter rows based on a condition.

Challenge 2 Filter Rows With Where

Explanation

  • WHERE category = 'Accessories' filters the table to only rows that match the condition.
  • The comparison is case-sensitive in many SQL systems.
  • Filtering early reduces the amount of data processed downstream.

Common Mistakes

  1. Forgetting quotes around text values
    WHERE category = Accessories -- ❌
  2. Using LIKE unnecessarily
  3. Putting WHERE before FROM

Optional Extension (Mini Bonus)

Try filtering:

  • Products with a price greater than 50
  • Products that are not in the Accessories category

(You’ll explore operators like >, <, and != very soon.)

Next Challenge

Beginner Challenge #3: Sort Results with ORDER BY

🔗 View reference solution on GitHub
(After you’ve tried the challenge)

Want more practical SQL challenges?
Subscribe to the Solve With SQL newsletter and get new problems delivered to your inbox.