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
ColumnType
idINT
nameTEXT
priceINT

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|Lamp
Explanation:

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|B
Explanation:

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|Q
Explanation:

Only products priced within the inclusive ten-to-fifty band are kept, returned by id.

Constraints

  • Use standard SQL (SQLite).

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.