I have a table with a FooId and a CreatedTime column. During the day, multiple rows can be inserted for the same FooId. The CreatedTime column represent the time at the moment of the inserting.
I would like a query which will return me the latest row for a given day (e.g. 2000-01-01). Is there a way to write a query which will do that with SQL Server 2005?
Below is an example of the data and the result that I am expecting. I would like the latest data created for the day. So the MAX(CreatedDate) won't work. Thanks!
FooId Data CreatedTime
---------------------------
1 A 2000/01/01 12:00:00
1 B 2000/01/01 12:12:00
1 C 2000/01/01 12:25:00
2 A 2000/01/01 12:00:00
2 B 2000/01/01 12:26:00
3 A 2000/01/01 12:00:00
Result
FooId Data CreatedTime
---------------------------
1 C 2000/01/01 12:25:00
2 B 2000/01/01 12:26:00
3 A 2000/01/01 12:00:00