This simple query tells you how many patients have charge entries in their ledgers between two dates.
The keyword DISTINCT in the COUNT() function eliminates duplicates.
SELECT
COUNT(DISTINCT ptnum)
FROM
sos.journal
WHERE
trantype = 'S'
AND amount > 0
AND trandate BETWEEN '2004-01-01' AND '2004-12-31'
Here’s a variation using the rv_charges view that breaks down the patient count by rendering provider. In
this case, we use rv_charges as an easy way to get to the provider code associated with the charges:
SELECT
provcode AS "Provider",
COUNT(DISTINCT ptnum) AS "Clients Seen"
FROM
sos.rv_charges
WHERE
amount > 0
AND trandate BETWEEN '2004-01-01' AND '2004-12-31'
GROUP BY
provcode