Select Queries: Finding the next record

  • Thread starter Thread starter Tammie
  • Start date Start date
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
 
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;
 
Suggest you post the relevant Table structure.

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