SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Departments with Salary Diversity

Build mastery in Subqueries with this scenario-based SQL challenge and live execution support.

Problem Statement

For each department compute salary_range = MAX(salary) − MIN(salary), then keep only those over $20,000 (and only departments that actually have employees). Return department_id, department_name, salary_range — ordered by salary_range DESC, department_id.

Relevant Tables

departmentsemployees

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: