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, 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')

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.