I am doing intermediate Sql. Does any one know what is wrong with code below | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I am doing intermediate Sql. Does any one know what is wrong with code below

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

1st Feb 2023, 10:48 PM
NURUDEEN USMAN
NURUDEEN USMAN - avatar
4 Answers
+ 4
I cannot see this course yet, but you have a syntax error, you need to put a comma before the CASE block
2nd Feb 2023, 5:49 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Please, do not write any code in post tags, it's better to use the post tags to specify relevant language name or lesson subject https://code.sololearn.com/W3uiji9X28C1/?ref=app
2nd Feb 2023, 6:29 AM
Ipang
+ 2
Add the task description clearly.. If iam at the right task description of this code, then along with syntax error ( camma is missing after salary,), task also says "output should be sorted by last name column in ascending order." So sort is missing in query.
2nd Feb 2023, 10:39 AM
Jayakrishna 🇮🇳
+ 1
Correct :Answer 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;
14th May 2023, 4:25 PM
Raul
Raul - avatar