SQL Practice Problem #002

Select product names and prices

Return only the product name and price columns from the products table.

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

idproduct_namecategorypricestock_count
1KeyboardAccessories49.9912
2MonitorDisplays2195

Output

Expected Output

product_nameprice
Keyboard49.99
Monitor219

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

Related Problems