I have a following table of dates:

```
dateID INT (PK),
personID INT (FK),
date DATE,
starttime VARCHAR, --Always in a format of 'HH:MM'

```

What I want to do is I want to pull rows (all columns, including PK) with lowest date (primary condition) and starttime (secondary condition) for every person. For example, if we have

row1(date = '2013-04-01' and starttime = '14:00') 

and 

row2(date = '2013-04-02' and starttime = '08:00') 

row1 will be retrieved, along with all other columns. 

So far I have come up with gradual filtering the table, but it`s quite a mess. Is there more efficient way of doing this?

Here is what I made so far:

```
    SELECT 
    D.id
    , D.personid
    , D.date        
    , D.starttime 
FROM table D 
JOIN (
        SELECT --Select lowest time from the subset of lowest dates
            A.personid, 
            B.startdate, 
            MIN(A.starttime) AS starttime 
        FROM table A 
        JOIN (
                SELECT --Select lowest date for every person to exclude them from outer table
                    personid
                    , MIN(date) AS startdate
                FROM table
                GROUP BY personid
            ) B
        ON A.personid = B.peronid
        AND A.date = B.startdate
        GROUP BY 
            A.personid, 
            B.startdate
    ) C
ON C.personid = D.personid
AND C.startdate = D.date 
AND C.starttime = D.starttime

```

It works, but I think there is a more clean/efficient way to do this. Any ideas?

EDIT: Let me expand a question - I also need to extract maximum date (only date, without time) for each person.

The result should look like this:

```
id
personid
max(date) for each person
min(date) for each person
min(starttime) for min(date) for each person

```

It is a part of a much larger query (the resulting table is joined with it), and the resulting table must be lightweight enough so that the query won`t execute for too long. With single join with this table (just using min, max for each field I wanted) the query took about 3 seconds, and I would like the resulting query not to take longer than 2-3 times that.