Hi
I have 2 tables that I want to run a complex query from but I do not know if my SQL is correct or if I can even do the query as I want it to run.
Here is my query screenshot so you can see the 2 tables I have in
Now for this query to work as intended I need the following to happen:
CASE
WHEN “Gross Salary” * 12 <= “TT1” THEN “Gross Salary” * 12 * “TB1” – “R” / 12
WHEN “Gross Salary” * 12 < “TT2” THEN (“Gross Salary” * 12 – “TT1”) * “TB2” + “TA2” – “R” / 12
WHEN “Gross Salary” * 12 < “TT3” THEN (“Gross Salary” * 12 – “TT2”) * “TB3” + “TA3” – “R” / 12
WHEN “Gross Salary” * 12 < “TT4” THEN (“Gross Salary” * 12 – “TT3”) * “TB4” + “TA4” – “R” / 12
WHEN “Gross Salary” * 12 < “TT5” THEN (“Gross Salary” * 12 – “TT4”) * “TB5” + “TA5” – “R” / 12
WHEN “Gross Salary” * 12 > “TT5” THEN (“Gross Salary” * 12 - “TT6”) * “TB6”+ “TA6” – “R” / 12
ELSE 0
END
I am not a pro just a novice user but I need this query to work out an amount for me.
Basicly it should get the “Gross Salary” amount from Table March and then look at the 6 conditions and do the corresponding equation to get the amount I need and if Gross salary does not meet 1 of the 6 conditions then the amount will be 0.
This is for HSQLDB embeded.
Any help will be appreciated.