I have a user request for a report and I’m too new to SQL programming to know how to approach it.

My user wants to know for each Staff ID what is the min, avg and max number of days between visits. What I don’t know how to figure out is the number of days between Visit 1 and Visit 2; Visit 2 and Visit 3, etc., for each Person ID. Some Person ID’s only have one visit, others (most) have multiple visits (up to 26). Here is a snapshot of some data (the full dataset is over 14k records):

```
PersonID    VisitNo    StaffID    VisitDate  
161          1         42344      06/19/2018
163          1         32987      05/14/2018
163          2         32987      09/17/2018
193          1         42344      04/09/2018
193          2         42344      07/18/2018
193          1         33865      07/18/2018  
207          1         32987      10/10/2018
207          2         32987      11/05/2018 
329          1         42344      04/15/2018
329          2         42344      05/23/2018
329          3         42344      06/10/2018
329          4         42344      07/18/2018
329          1         33865      06/30/2018
329          2         33865      09/14/2018

```

My research found a lot of references to comparing rows in the same table and I figured out how to compare one visit to the next for a single PersonID using a self join and datadiff, but how do I get from one PersonID to the next, or skip those PersonID’s with only 1 visit? Or a PersonID who has visits with multiple StaffId's?

Any ideas/suggestions are greatly appreciated as I have two requests that will benefit.