I have a table, Students, with the following columns:
| id | name | class | date_registrered |
I want to select one row for every unique class, and only the row with the largest value in date_registrered,
i.e. I want to select the latest registrered Student, including all the data for that one.
SELECT id, name, class, MAX(date_registrered) FROM Students GROUP BY class;
I get the following error:
Column 'Students.id' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Does anyone know how to fix this?