SELECT STUDENT_ID SUM(MARKS)
FROM MARKS WHERE MARKS>=500
ORDER BY MARKS DESC
GROUP BY STUDENT_ID;
above is my query and i am getting the following error:
ERROR 1064 (42000) at line 6: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUM(MARKS) FROM marks WHERE MARKS>=500 ORDER BY MARKS DESC GROUP BY STUD' at line 1
can anyone help in it.
CodePudding user response:
SELECT M.STUDENT_ID, SUM(M.MARKS) AS SUM_MARKS
FROM MARKS M
WHERE M.MARKS>=500
GROUP BY M.STUDENT_ID
ORDER BY SUM_MARKS DESC;
CodePudding user response:
Comma after STUDENT_ID; the SELECT list is a comma delimited list of expressions.
CodePudding user response:
Try this:
SELECT M.STUDENT_ID, SUM(M.MARKS) AS SUM_MARKS
FROM MARKS M
WHERE M.MARKS>=500
GROUP BY M.STUDENT_ID
ORDER BY SUM(M.MARKS) DESC;
