0
Intermediate sql taxes
Here is my code: SELECT firstname, lastname, salary, CASE WHEN salary >= 0 AND salary <= 1500 THEN salary*0.1 WHEN salary <= 1501 AND salary >= 2000 THEN salary* 0.2 ELSE salary*0.3 END AS tax FROM Employees ORDER BY lastname ASC; It failed. Can someone help me with this?
3 Answers
+ 2
You had used the wrong operators in fifth line. Write it as:
>= and next is <=
0
I already solved it .thanks.
0
SELECT firstname, lastname, salary,
CASE
WHEN salary >= 0 and salary<=1500 then salary * 0.1
WHEN salary >= 1501 and salary<=2000 then salary * 0.2
WHEN salary >= 2001 then salary * 0.3
END as tax
FROM Employees
ORDER BY lastname ASC ;