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_name | type | description |
|---|---|---|
| product_id | INTEGER | Unique product ID |
| name | TEXT | Product name |
| category | TEXT | Product category |
| price | DECIMAL | Product price |
| stock_qty | INTEGER | Units in stock |
| created_at | TIMESTAMP | When the product was created |
Sample Data (for context)
| product_id | name | category | price | stock_qty |
|---|---|---|---|---|
| 101 | Wireless Mouse | Accessories | 24.99 | 120 |
| 102 | Mechanical Keyboard | Accessories | 89.00 | 45 |
| 103 | 27-inch Monitor | Displays | 229.99 | 18 |
| 104 | USB-C Hub | Accessories | 34.50 | 70 |
| 105 | Laptop Stand | Workspace | 39.99 | 32 |
Your Task
Write a SQL query that returns only products in the Accessories category, showing:
namepricecategory
Expected Output
| name | price | category |
|---|---|---|
| Wireless Mouse | 24.99 | Accessories |
| Mechanical Keyboard | 89.00 | Accessories |
| USB-C Hub | 34.50 | Accessories |
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.

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
- Forgetting quotes around text values
WHERE category = Accessories -- ❌ - Using
LIKEunnecessarily - Putting
WHEREbeforeFROM
Optional Extension (Mini Bonus)
Try filtering:
- Products with a price greater than 50
- Products that are not in the
Accessoriescategory
(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.