Our practice has 40+ therapists and we would like to be able to give
them a simple monthly report showing account balances due by patients.
SELECT
prv.provcode AS "primary provider", pt.lastname, pt.firstname, pt.id, bal.ptbalance
FROM
sos.patients pt
JOIN sos.providers prv ON pt.providernum = prv.providernum
JOIN sos.PT_NONINSBALANCE bal ON pt.ptnum = bal.ptnum
WHERE
pt.flag = 0
AND pt.dischargedate IS NULL
AND pt.licnum = 101
ORDER BY "primary provider"