Problem
Task
Return only the product name and price columns from the products table.
Schema
Table Schema
products(id, product_name, category, price, stock_count)
Input
Sample Data
| id | product_name | category | price | stock_count |
|---|---|---|---|---|
| 1 | Keyboard | Accessories | 49.99 | 12 |
| 2 | Monitor | Displays | 219 | 5 |
Output
Expected Output
| product_name | price |
|---|---|
| Keyboard | 49.99 |
| Monitor | 219 |
Answer
Check Your Solution
Show Answer and Explanation
Correct Answer
SELECT product_name, price
FROM products;
Explanation
SELECT controls which columns appear in the result. Because the problem asks only for product names and prices, the query should not include id, category, or stock_count.
Common Mistakes
- Using SELECT * even though the task asks for specific columns.
- Misspelling product_name or using a display label as a column name.
- Changing the row order when the problem does not ask for sorting.
Concepts
Related Concepts
SELECT
Column Projection
Result Sets
Projection
Columns
Next practice