Compensation analytics teams use salary quartiles to benchmark pay equity and flag outliers. By assigning each employee a percentile band, HR can quickly see whether the distribution matches hiring intent — for example, whether senior engineers really do cluster in P75 and P100. Using the employees table, return name, salary, and salary_percentile (P25 / P50 / P75 / P100 based on NTILE(4)), ordered by salary ascending.
employees
| column | type |
|---|---|
| id | INTEGER |
| name | TEXT |
| department | TEXT |
| salary | NUMERIC |
employees
| id | name | department | salary |
|---|---|---|---|
| 1 | Alice | Engineering | 50000 |
| 2 | Bob | Marketing | 60000 |
| 3 | Carol | Engineering | 70000 |
| 4 | Dave | HR | 80000 |
| 5 | Eve | Marketing | 90000 |
| 6 | Frank | Engineering | 100000 |
| 7 | Grace | HR | 110000 |
| 8 | Hank | Engineering | 120000 |
| name | salary | salary_percentile |
|---|---|---|
| Alice | 50000 | P25 |
| Bob | 60000 | P25 |
| Carol | 70000 | P50 |
| Dave | 80000 | P50 |
| Eve | 90000 | P75 |
| Frank | 100000 | P75 |
| Grace | 110000 | P100 |
| Hank | 120000 | P100 |
With 8 employees and 4 buckets, NTILE(4) places 2 employees in each bucket. The two lowest-paid (Alice and Bob) are labeled P25; the two highest-paid (Grace and Hank) are labeled P100.