Search code examples
sqloracle-databaseinner-join

Calculate the taxable % for each employee using sql developer between two tables


I need to design a sql developer query in such a way to get the desired output table using table1 and table2.

Table1: Employee Table as per the below image https://i.sstatic.net/O4oyj.png

Table2: Tax Slab Table as per the below image https://i.sstatic.net/XBZ3b.png

Display the Tax_Percentage value in Table2 against the Emp ID and Salary Range in Table1

Need the out as per this Output table - https://i.sstatic.net/fOVNu.png


Solution

  • You can join with inequality conditions:

    select e.empid, e.salary, t.tax_percentage
    from employee e
    inner join tax t on e.salary >= t.start_range and e.salary < t.end_rage