Skip to content

1468. Calculate Salaries 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
WITH
  SalariesWithMaxSalary AS (
    SELECT
      *,
      MAX(salary) OVER(PARTITION BY company_id) AS max_salary
    FROM Salaries
  )
SELECT
  company_id,
  employee_id,
  employee_name,
  ROUND(
    CASE
      WHEN max_salary < 1000 THEN salary
      WHEN max_salary BETWEEN 1000 AND 10000 THEN salary * 0.76
      ELSE salary * 0.51
    END
  ) AS salary
FROM SalariesWithMaxSalary;