Let's assume we have an "Employee" table containing "ID", "Name", "Department", and "Salary". First, we need to find the median salary using the following SQL query: SELECT AVG(salary) AS Median FROM( SELECT salary, COUNT(salary) OVER() AS cnt, ROW_NUMBER() OVER(ORDER BY salary) AS rownum FROM Employee) x WHERE rownum IN ((cnt + 1) / 2, (cnt + 2) / 2) Next, we will compute the deviation of each salary from the median: SELECT ID, Name, Salary, ABS(Salary - Median) AS Deviation FROM Employee, (<the previous table>) AS MedianTable Lastly, we will rank these deviations: SELECT ID, Name, Salary, RANK() OVER (ORDER BY Deviation) AS Rank FROM (<the previous table>)