Challenge 1: Select Specific Columns (Without Overfetching)

Difficulty: Beginner
Estimated time: 5–10 minutes
SQL concepts: SELECT, choosing columns, result sets
Goal: Retrieve only the columns you need (a core real-world SQL habit).

The Scenario

You’re working with an e-commerce database. A product manager asks for a simple list of products showing:

  • Product name
  • Price
  • Category

They do not want internal columns like IDs, created timestamps, or inventory details.

Your task is to write a query that returns only the requested columns.

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_qtycreated_at
101Wireless MouseAccessories24.991202025-01-10 09:00:00
102Mechanical KeyboardAccessories89.00452025-01-12 10:30:00
10327-inch MonitorDisplays229.99182025-01-15 12:20:00
104USB-C HubAccessories34.50702025-01-18 14:00:00
105Laptop StandWorkspace39.99322025-01-21 16:10:00

Your Task

Write a SQL query that returns:

  • name
  • price
  • category

From the products table.

Expected Output

Your result should look like this:

namepricecategory
Wireless Mouse24.99Accessories
Mechanical Keyboard89.00Accessories
27-inch Monitor229.99Displays
USB-C Hub34.50Accessories
Laptop Stand39.99Workspace

Constraints

  • Do not use SELECT *
  • Return only the three requested columns
  • The column order should be: name, price, category

Hint (Optional)

In SQL, you specify the columns you want right after SELECT, separated by commas.

SELECT
name,
price,
category
FROM products;

Explanation

  • SELECT name, price, category tells the database exactly which columns to return.
  • FROM products tells it which table to read from.
  • This avoids pulling unnecessary data, which is more efficient and is best practice in production SQL.

Common Mistakes

  1. Using SELECT *
    • Works, but returns extra columns you didn’t ask for (and often slows real systems).
  2. Wrong column order
    • Many automated checkers and dashboards expect a specific ordering.
  3. Misspelling column names
    • SQL will error if category is typed incorrectly.

Optional Extension (Mini Bonus)

Modify your query to return only products where the category is Accessories.

(You’ll learn WHERE in Challenge #2, but it’s fine to try.)

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