I like Mickey's answer from Quassnoi (and supported Mickey), but if your needs are similar to mine, you should keep in mind some limitations. First and foremost, it only works if you are looking for the most recent entry or the most recent entry for a single name. If you need the last entry for each person in the set (one entry per person, but the last entry for each), then the above solutions do not justify themselves. Secondly, and less importantly, if you work with large data sets, it can be a little slow in the long run. So what is work?
What I am doing is adding a bit to the table labeled "newest". Then, when I store a record (which runs in a stored procedure in SQL Server), I follow this pattern:
Update Table Set Newest=0 Where Name=@Name Insert into Table (Name, dateTimeVal, Data, Newest) Values (@Name, GetDate(), @Data, 1);
In addition, there is an index in Name and Newest to make the selection very quick.
Then select "Select":
Select dateTimeVal, Data From Table Where ( Name=@Name ) and (Newest=1);
The selection for the group will look something like this:
Select Name, dateTimeVal, Data from Table Where (Newest=1);
If entries cannot be entered in date order, your logic is slightly different:
Update Table Set Newest=0 Where Name=@Name Insert into Table (Name, dateTimeVal, Data, Newest) Values (@Name, GetDate(), @Data, 0);
The rest remains unchanged.