company_id
and the maximum salary for each company from the Salaries
table.CASE
statement within the subquery to determine the tax rate based on the maximum salary.Salaries
table on company_id
.CASE
statement to calculate the taxed salary for each employee by applying the tax rate to their salary.ROUND
function to round the taxed salary to the nearest integer.company_id
, employee_id
, employee_name
, and the calculated taxed salary
) for the final output.erDiagram Salaries { int company_id int employee_id varchar employee_name int salary company_id employee_id PK }