Products In Price Range
EasySQLDatabaseSorting
Description
Write a SQL query to return the id and name of products whose price is between 10 and 50 inclusive, ordered by id ascending. **Output columns (in order):** id, name
Table:
products| Column | Type |
|---|---|
| id | INT |
| name | TEXT |
| price | INT |
Examples
Input:
CREATE TABLE products (id INT, name TEXT, price INT); INSERT INTO products VALUES (1,'Pen',5),(2,'Mug',25),(3,'Lamp',50),(4,'Desk',200);Output:
2|Mug
3|LampExplanation:
Only products priced within the inclusive ten-to-fifty band are kept, returned by id.
Input:
CREATE TABLE products (id INT, name TEXT, price INT); INSERT INTO products VALUES (1,'A',10),(2,'B',49),(3,'C',9);Output:
1|A
2|BExplanation:
Only products priced within the inclusive ten-to-fifty band are kept, returned by id.
Input:
CREATE TABLE products (id INT, name TEXT, price INT); INSERT INTO products VALUES (3,'Q',30),(1,'P',15),(2,'R',60);Output:
1|P
3|QExplanation:
Only products priced within the inclusive ten-to-fifty band are kept, returned by id.
Constraints
- •
Use standard SQL (SQLite).