ROW_NUMBER() window function to assign a row number to each salary within each company, ordered by salary and id.COUNT() window function to get the total number of employees in each company.(count + 1) / 2; if even, use count / 2 and count / 2 + 1).
erDiagram
Employee {
int id PK "The unique identifier for an employee"
varchar company "The company where the employee works"
int salary "The salary of the employee"
}