I have this table in my database:
classes
id | classname |
grades
id | class_id | grade | date
I need to get the average of the grades and the latest grade based on the date + the correct classname.
I have this query but this doesn't output the correct classnames...
SELECT
AVG(grade),
classes.classname,
grades.grade,
MIN(ABS(DATEDIFF(CURDATE(),'date')))
FROM
grades, classes
GROUP BY
grades.grade_id
ORDER BY grades.date DESC