0
0
SQLquery~30 mins

ORDER BY single column in SQL - Mini Project: Build & Apply

Choose your learning style9 modes available
Sorting Products by Price Using ORDER BY
📖 Scenario: You work at a small online store. You have a table of products with their prices. You want to see the products sorted by their price from lowest to highest.
🎯 Goal: Create a SQL query that selects all products and sorts them by the price column in ascending order using ORDER BY.
📋 What You'll Learn
Create a table called products with columns id, name, and price.
Insert three products with exact values: (1, 'Pen', 1.20), (2, 'Notebook', 2.50), (3, 'Eraser', 0.80).
Write a SQL query to select all columns from products.
Use ORDER BY price to sort the results by the price column in ascending order.
💡 Why This Matters
🌍 Real World
Sorting products by price helps customers find cheaper or more expensive items easily on online stores.
💼 Career
Knowing how to use ORDER BY is essential for database querying and reporting in many jobs like data analysis, backend development, and database administration.
Progress0 / 4 steps
1
Create the products table and insert data
Create a table called products with columns id (integer), name (text), and price (decimal). Then insert these exact rows: (1, 'Pen', 1.20), (2, 'Notebook', 2.50), and (3, 'Eraser', 0.80).
SQL
Need a hint?

Use CREATE TABLE to define the table and INSERT INTO to add rows.

2
Write a basic SELECT query
Write a SQL query to select all columns from the products table using SELECT * FROM products.
SQL
Need a hint?

Use SELECT * FROM products; to get all rows and columns.

3
Add ORDER BY clause to sort by price
Modify the SELECT query to add ORDER BY price so the products are sorted by the price column in ascending order.
SQL
Need a hint?

Use ORDER BY price after the FROM clause to sort by price.

4
Complete the query with explicit ASC keyword
Add the keyword ASC after ORDER BY price to explicitly specify ascending order.
SQL
Need a hint?

Use ORDER BY price ASC to sort ascending explicitly.