+ 3
Can anyone tell me why this code is wrong đ€
SELECT firstname, lastname, salary, CASE WHEN salary <= 1500 THEN '0.1' WHEN salary >= 1501 AND salary <= 2000 THEN '0.2' ELSE '0.3' END AS tax FROM Employees ORDER BY lastname ASC;
6 Answers
+ 2
you are supposed to multiply the salary by the tax.
also, sort the result by lastname in ascending order.
+ 2
Thank you to everyone who supports me. It's very simple, but I was confused. I got the right code đđ
SELECT firstname, lastname, salary,
CASE
WHEN 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;
+ 1
How about review the previous chapter "Math & Aggregate Functions"?
The very first page shows how to have a selected field calculated on the fly.
+ 1
instead of just displaying '0.1','0.2' and '0.3' compute salary*0.1, salary*0.2 and salary*0.3
0
Bob_Li I
I changed my code according to your advice as ORDER BY lastname ASC;
But I don't know how multiple the salary by tax?????
0
You are suppose to select the column and not the row inside the column