I have not ever worked on triggers in SQL Server 2008. So I don’t have any idea how to do it.
I have a game application, I’m keeping track of the number of questions played & total number of questions answered correctly. I’m also saving the average time taken for each question played.
Now I want to record the rank depending upon percentage of answers correct and If there is a tie we will check the time taken. I have to do all this using triggers.
id | playerID | CompetitionID | NoOfCOrrectANswers | NoOfPlayedQuestions | TimeTaken
-----------------------------------------------------------------------------------------
1 3 203 4 8 8.4
2 56 203 9 18 13
3 67 203 16 45 15
Any help is appreciated. Thanks in advance.
You probably should not take this road as number of updates will be high. You might add row_number() or rank() function to a query that presents results of a competition.
That being said, if you feel that you absolutely must persist ranking info in a table, add a column
and create a trigger on ATable