Last Visit Betwween Report/Query Help

For users or potential users.
Post Reply
spolevoy
Posts: 74
Joined: Wed Oct 17, 2012 4:45 am

Last Visit Betwween Report/Query Help

Post by spolevoy » Sun Jan 19, 2014 11:27 am

I'm trying to come up with a very simple report - Guarantors with mailing info for Last Visit Date between '2010-01-01' and '2013-01-01'.
Should be pretty simple, but I am not sure how to use the <> in the Patients Raw report, and no query in the sample query list has a date range.

Thanks!!!

User avatar
Arna
Posts: 444
Joined: Tue Jul 09, 2013 3:16 pm

Re: Last Visit Betwween Report/Query Help

Post by Arna » Mon Jan 27, 2014 4:32 pm

Sorry for the late reply. Does this give you what you are looking for?

SET @pos=0, @FromDate='2010-01-01' , @ToDate='2013-01-01';
SELECT
guarantor,
COUNT(DISTINCT patient.patnum) AS Dependents,
/*@pos:=@pos+1 as 'Count',*/
LName,
GROUP_CONCAT(DISTINCT (FName)),
DATE_FORMAT(MAX(ProcDate), '%m/%d/%Y') AS 'LastVisit',
Address,
Address2,
City,
State,
Zip
FROM
patient
INNER JOIN procedurelog
ON procedurelog.PatNum = patient.PatNum
WHERE procedurelog.ProcStatus = 2
AND PatStatus = 0
GROUP BY Guarantor
HAVING MAX(ProcDate) BETWEEN @FromDate
AND @ToDate
ORDER BY Lname ;
Entropy isn't what it used to be...

Arna Meyer

Post Reply