Even-Id Items
EasySQLDatabaseSorting
Description
Write a SQL query to return the id and name of items whose id is even, ordered by id ascending. **Output columns (in order):** id, name
Table:
items| Column | Type |
|---|---|
| id | INT |
| name | TEXT |
Examples
Input:
CREATE TABLE items (id INT, name TEXT); INSERT INTO items VALUES (1,'A'),(2,'B'),(3,'C'),(4,'D');Output:
2|B
4|DExplanation:
Keeping rows whose id divides evenly by two returns the even-numbered items by id.
Input:
CREATE TABLE items (id INT, name TEXT); INSERT INTO items VALUES (2,'P'),(4,'Q'),(6,'R');Output:
2|P
4|Q
6|RExplanation:
Keeping rows whose id divides evenly by two returns the even-numbered items by id.
Input:
CREATE TABLE items (id INT, name TEXT); INSERT INTO items VALUES (10,'M'),(7,'N');Output:
10|MExplanation:
Keeping rows whose id divides evenly by two returns the even-numbered items by id.
Constraints
- •
Use standard SQL (SQLite).