SQL
All Top 50 SQL Interview Questions#20
Non-Equi Joins for Tier Banding and Tax Brackets in SQL
MediumInterview Question #20
Given `employees` (emp_id, name, salary) and `salary_grades` (grade, min_salary, max_salary), assign each employee to their appropriate salary grade using a non-equi join.
Input Table: employees & salary_grades
2 rows preview| emp_id | salary | grade | min_salary | max_salary |
|---|---|---|---|---|
| 1 | 45000 | Grade A | 0 | 50000 |
| 2 | 75000 | Grade B | 50001 | 100000 |
Expected Output Structure2 rows
| emp_id | name | salary | grade |
|---|---|---|---|
| 1 | Sachin | 45000 | Grade A |
| 2 | Shreya | 75000 | Grade B |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.