Consider the following data set in a “book” table (group_id, title, check_out_date):
> 1 - "Moby Dick" - 2010-01-01
> 1 - "The Jungle Book" - 2011-05-05
> 1 - "Grapes of Wrath" - 1999-01-12
> 2 - "Huckleberry Finn" - 2000-01-05
> 2 - "Tom Sawyer" - 2011-06-12
I need to write a query that will return the record with the oldest “check_out_date” value from each group (Group 1 and Group 2). This should be fairly easy — I just don’t know how to do it.
I think you need something like this.