I need to compare rows in the same table of a query.
Here is an example of the table:
id checkin checkout
1 01/15/13 01/31/13
1 01/31/13 05/20/13
2 01/15/13 05/20/13
3 01/15/13 01/19/13
3 01/19/13 05/20/13
4 01/15/13 02/22/13
5 01/15/13 03/01/13
I compare the checkout date to today's date, if it is before today's date then I want to return the result. However, similar to id's 1 and 3, they have multiple records. If one of the records associated with the same id have a record that has a checkout date after today's date then I don't want to return any of their records. I only want to return a record of each id where every record is before today's date in the checkout field.