Here is my sample data
Patient_ID Visit_Number Last_Visit
----------- ------------ -----------
9283 1 Jan 20 2003
6372 2 Jan 20 2003
7347 3 Jan 20 2003
2372 4 Jan 20 2003
8493 5 Jan 20 2003
4283 6 Jan 20 2003
7698 7 Jan 20 2003
5382 8 Jan 20 2003
8392 9 Jan 20 2003
3238 10 Jan 21 2003
4283 11 Jan 21 2003
2322 12 Jan 21 2003
9283 13 Jan 21 2003
7698 14 Jan 21 2003
6293 15 Jan 21 2003
7347 16 Jan 21 2003
1328 17 Jan 21 2003
5382 18 Jan 22 2003
9283 19 Jan 22 2003
8493 20 Jan 22 2003
1382 21 Jan 22 2003
7347 22 Jan 22 2003
8392 23 Jan 22 2003
3832 24 Jan 22 2003
9283 25 Jan 22 2003
What i need to do is find the Patient_ID who had the longest time in days between appointments. I been trying to figure this out for my work, but haven't been able to get it yet. I got a feeling that it's something simple too.
Patient_ID Visit_Number Last_Visit
----------- ------------ -----------
9283 1 Jan 20 2003
6372 2 Jan 20 2003
7347 3 Jan 20 2003
2372 4 Jan 20 2003
8493 5 Jan 20 2003
4283 6 Jan 20 2003
7698 7 Jan 20 2003
5382 8 Jan 20 2003
8392 9 Jan 20 2003
3238 10 Jan 21 2003
4283 11 Jan 21 2003
2322 12 Jan 21 2003
9283 13 Jan 21 2003
7698 14 Jan 21 2003
6293 15 Jan 21 2003
7347 16 Jan 21 2003
1328 17 Jan 21 2003
5382 18 Jan 22 2003
9283 19 Jan 22 2003
8493 20 Jan 22 2003
1382 21 Jan 22 2003
7347 22 Jan 22 2003
8392 23 Jan 22 2003
3832 24 Jan 22 2003
9283 25 Jan 22 2003
What i need to do is find the Patient_ID who had the longest time in days between appointments. I been trying to figure this out for my work, but haven't been able to get it yet. I got a feeling that it's something simple too.