I have a situation where people need to pick football matches where they think there will be at least one goal scored. The person with the longest consecutive series wins a prize. Waheey
So i have a table with user data where i can identify a user with an ID.
Then i have a table with football matches each one having a unique ID and containing a timestamp for kickoff and a boolean indicating if the result is in and a boolean indicating if there was a goal in the match.
And then i have a table linking the user ID's to the match ID's.
The boolean result is used to eliminate any record for which the result is not yet known. The order is determined by kickoff and then team names.
So i end up with this:
userID , matchID, kickoff, home, away, result, goal
1, 2354 , 2011-05-21 17:00:00 , TeamA, TeamB, true , true
1, 1354 , 2011-05-21 19:00:00 , TeamA, TeamB, true , true
1, 3454 , 2011-05-21 19:00:00 , TeamA, TeamB, true , true
1, 4354 , 2011-05-21 20:00:00 , TeamA, TeamB, true , false
1, 3754 , 2011-05-21 20:15:00 , TeamA, TeamB, true , true
1, 6654 , 2011-05-21 21:00:00 , TeamA, TeamB, true , true
1, 2854 , 2011-05-21 21:00:00 , TeamA, TeamB, true , false
The question is what is the best/easiest/simplest/ANY way to find out the longest consecutive sequence. So in this case i'm looking to find out the first 3 records as those 3 are the longest series in this example.