Query question
Posted: Thu Sep 25, 2008 9:22 am
Hi.
I took Dr. Bonilla's query,
39. List of patients and their addresses who have not been seen since a certain date (the example uses Sept 1, 2005). It will also give you the date of their last visit. Submitted by Jorge Bonilla, DMD
SELECT patient.LName, patient.FName, patient.Address, patient.Address2, patient.City, patient.State, patient.Zip, procedurelog.procdate
FROM patient,procedurelog
WHERE procedurelog.PatNum=patient.PatNum
AND procedurelog.procstatus = '2'
GROUP BY procedurelog.PatNum
HAVING MAX(procdate) < '2005-09-01'
and modified it so that it filtered out bad accounts and inactive pt.s
SELECT patient.LName, patient.FName, patient.Address, patient.Address2, patient.City, patient.State, patient.Zip, procedurelog.procdate
FROM patient,procedurelog
WHERE procedurelog.PatNum=patient.PatNum
AND procedurelog.procstatus = '2'
AND (patient.BillingType = '40')
AND PatStatus = '0'
GROUP BY procedurelog.PatNum
HAVING MAX(procdate) < '2008-03-01'
However, the table that show procdate does not show date pt.'s last visit, as indicated in Dr. Bonilla's description, but rather their first visit. How do we make it so that it actually shows date of last visit?
I took Dr. Bonilla's query,
39. List of patients and their addresses who have not been seen since a certain date (the example uses Sept 1, 2005). It will also give you the date of their last visit. Submitted by Jorge Bonilla, DMD
SELECT patient.LName, patient.FName, patient.Address, patient.Address2, patient.City, patient.State, patient.Zip, procedurelog.procdate
FROM patient,procedurelog
WHERE procedurelog.PatNum=patient.PatNum
AND procedurelog.procstatus = '2'
GROUP BY procedurelog.PatNum
HAVING MAX(procdate) < '2005-09-01'
and modified it so that it filtered out bad accounts and inactive pt.s
SELECT patient.LName, patient.FName, patient.Address, patient.Address2, patient.City, patient.State, patient.Zip, procedurelog.procdate
FROM patient,procedurelog
WHERE procedurelog.PatNum=patient.PatNum
AND procedurelog.procstatus = '2'
AND (patient.BillingType = '40')
AND PatStatus = '0'
GROUP BY procedurelog.PatNum
HAVING MAX(procdate) < '2008-03-01'
However, the table that show procdate does not show date pt.'s last visit, as indicated in Dr. Bonilla's description, but rather their first visit. How do we make it so that it actually shows date of last visit?