I'm trying to get the latest odds just before kick off for football games using Betfair's historical data. My database looks as follows:
Now Betfair's historical data records the odds many times a day and therefore has lots of duplicate data. I have so far managed to only get all the odds for the selected Correct Score markets before kickoff.
As you can see there are duplicate records but I want to be able to only get the latest (max) time for each of the Correct Scores. I have highlighted the rows that I want the final query to only output.
My SQL statement is as follows:
SELECT "SCHEDULED_OFF", "FULL_DESCRIPTION", "EVENT",
"SELECTION_ID", "SELECTION", "ODDS", "WIN_FLAG", "LATEST_TAKEN"
FROM "bfinf_other_161017to161023_161026123339"
WHERE "FULL_DESCRIPTION" LIKE 'English Soccer/English Premier League%'
AND "EVENT" = "Correct Score"
AND "LATEST_TAKEN" < "SCHEDULED_OFF"
ORDER BY "FULL_DESCRIPTION" ASC, "SELECTION" ASC, "LATEST_TAKEN" DESC
I've tried to GROUP BY "FULL_DESCRIPTION" and "SELECTION" but nothing seems to be happening.
Any help would be greatly appreciated thanks.
Michael