Salary Bands
MediumSQLDatabaseSorting
Description
Write a SQL query to return each employee id and a band: 'High' when salary is at least 100000, 'Mid' when at least 50000, otherwise 'Low'. Order by id ascending. **Output columns (in order):** id, band
Table:
employees| Column | Type |
|---|---|
| id | INT |
| salary | INT |
Examples
Input:
CREATE TABLE employees (id INT, salary INT); INSERT INTO employees VALUES (1,120000),(2,60000),(3,30000);Output:
1|High
2|Mid
3|LowExplanation:
Each salary is mapped to a band by checking the thresholds from highest down, returned by id.
Input:
CREATE TABLE employees (id INT, salary INT); INSERT INTO employees VALUES (1,50000),(2,49999),(3,100000);Output:
1|Mid
2|Low
3|HighExplanation:
Each salary is mapped to a band by checking the thresholds from highest down, returned by id.
Input:
CREATE TABLE employees (id INT, salary INT); INSERT INTO employees VALUES (1,10);Output:
1|LowExplanation:
Each salary is mapped to a band by checking the thresholds from highest down, returned by id.
Constraints
- •
Use standard SQL (SQLite).