HSBC & Atlassian SQL Interview Question ( Hard Level) | Calculate Salaries 💡

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ม.ค. 2025

ความคิดเห็น • 6

  • @PulkitSrivastava22
    @PulkitSrivastava22 หลายเดือนก่อน

    Well explained Sneha!

  • @Savenature635
    @Savenature635 หลายเดือนก่อน

    My approach :
    with cte as (select *,max(salary) over(partition by company_id) as max_salary
    from Salaries), cte_2 as (
    select *,cast(case when max_salary 10000 then 49 else null end as float) / 100 as tax_rate
    from cte)
    select company_id,employee_id,employee_name,
    round(salary-(salary*tax_rate),0) as calculated_salary
    from
    cte_2;

  • @RitikaAgarwal-m9h
    @RitikaAgarwal-m9h 2 หลายเดือนก่อน

    we should do salary + tax right, to get the salary after applying taxes, why are we subtracting can you please explain

    • @biramdevpawar9902
      @biramdevpawar9902 2 หลายเดือนก่อน +1

      We are deducting taxable amount from the total salary

    • @DatacraftingWithSneha
      @DatacraftingWithSneha  2 หลายเดือนก่อน

      We're subtracting the tax from the salary because tax is something that gets taken away from the employee's salary, not added to it. This helps us find the actual salary after tax.
      For example, if an employee's salary is $2000 and the tax rate is 24%, we subtract 24% from their salary like this:
      Actual Salary = Salary - (Tax * Salary).