Site icon SOS Resources

List Cities with Number of Patients Seen

This query produces a list of cities and the number of patients in each one who have been seen during a specified date range.

SELECT b.city, count(distinct a.ptnum) as "Count"
FROM patients a JOIN payors b ON a.payornum = b.payornum
WHERE a.ptnum IN (SELECT ptnum FROM journal 
                  WHERE trantype = 'S' 
                  AND trandate BETWEEN '2012-11-01' AND '2013-06-30')
GROUP BY b.city
ORDER BY b.city
Exit mobile version