Assign a number to each row based on the date within each home group, starting with the most recent date first. After that, just choose the rows with the number 1.These will be the most up-to-date entries for each home.
To implement this refer the below code:
SELECT id, home, datetime, player, resource
FROM (
SELECT *,
ROW_NUMBER() OVER (PARTITION BY home ORDER BY datetime DESC) AS row_num
FROM your_table
) AS ranked
WHERE row_num = 1;
It will give you the output:
id home datetime player resource
---|-----|------------|--------|---------
1 | 10 | 04/03/2009 | john | 399
2 | 11 | 04/03/2009 | juliet | 244
5 | 12 | 04/03/2009 | borat | 555
8 | 13 | 01/01/2009 | borat | 700