I'm creating a quiz, and I'm storing responses from players in a SQL Server database.
Table: tblResponses
Columns:
rId (indexed primary key)
rQuestion (links to tblQuestions)
rResponse (the player's response, links to tblAnswers)
rTimeLeft (timestamp of when answer was added)
rPlayerId (uniqueidentifier, linked to tblPlayers)
Normal operation is fine (reading/writing) but I'm crafting a reporting system and have come a cropper thanks to one feature:
Players can revisit a question and change their answer, which creates a new row in the 'responses' table.
I need to select only the most recent answer in the reports (in this case based on a specific question ID), so if one player has changed their answer at some point I only want to return one record rather than two.
The answer's probably blindingly obvious but I've been looking at it for so long now, obvious is beyond my grasp.
Can anyone help?