SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Rank Employees and Find Those in Top 25% by Salary

Build mastery in Ranking Nth Value with this scenario-based SQL challenge and live execution support.

Problem Statement

Find employees in the top 25% salary bracket. The textbook primitive is `NTILE(4)` — it partitions rows into 4 equal-sized buckets numbered 1..4. The top quartile is bucket 1 (because we sort salary DESC). Show first_name, last_name, salary, quartile, ordered by salary DESC, employee_id.

Relevant Tables

employees

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: