Select Queries: Finding the next record

T

Tammie

I have a database containing a few thousand people. I
constructed a querie that returned the date of their first
visit. Now, I want to know the date of their second
visit. Does anyone have any idea how to do this? It
can't possibly be as difficult as I'm making it! Thanks
 
K

Ken Snell

Something like this, perhaps:

SELECT Max(TableName.VisitDate),
TableName.PersonIDField,
TableName.PersonNameField
FROM TableName
WHERE TableName.VisitDate <
(SELECT Max(T.VisitDate) FROM
TableName AS T
WHERE T.PersonIDField = TableName.PersonIDField)
GROUP BY TableName.PersonNameField;
 
V

Van T. Dinh

Suggest you post the relevant Table structure.

This sort of queries can be difficult since it is likely that you need
SubQueries!
 
Top