Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restrict query to calculate on last record for each subject 1

Status
Not open for further replies.

ad2

Technical User
Joined
Dec 31, 2002
Messages
186
Location
US
Hi,

I have a query which calculates when patient's next 6 month appt is due, based on the date of their last visit.

It is working fine except it calculate and displays all the patient's records, not just their last appointment and the date 6 months out.

How do I restrict the query to run only on the last visit date and calculate the 6 months out?

Current SQL is:

SELECT PatID, VisDate, [VisDate]+180 AS [Next 6 Month Appt Date]
FROM tblExam;

Thanks!
 
How about...
Code:
SELECT PatID, Max(VisDate) As LastVisit, LastVisit + 180 As NextVisit FROM tblExam


Randy
 
Code:
SELECT PatID, Max(VisDate) As LastVisit, LastVisit + 180 As NextVisit FROM tblExam
group by PatID
 
Thanks Randy700 and pwise, this is most helpful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top