I am working with a system that stores students' responses to questions in a table by creating a new entry each time the student resubmits his/her answer. I only want the final answer though. I have looked at some of the greatest-n-per-group posts on here and have attempted to apply some of those queries, but they haven't yielded the results I was hoping for yet. The closest that I have gotten was getting the most recent answer to the most recent question, but I need answers to every question that the student has responded to. Below is the closest that I have gotten so far.
select t1.* from response_history as t1
LEFT OUTER JOIN response_history as t2
ON t1.student_id = t2.student_id
AND (t1.`date` > t2.`date`
OR (t1.`date` = t2.`date` AND t1.id > t2.id))
where t2.student_id IS NULL;