Is there a query that will list all clients that were seen in a certain time frame along with name of insurance for a specific provider?
Adjust the desired date range and provider code in the WHERE clause below.
SELECT DISTINCT
a.lastname,
a.firstname,
a.id,
a.provcode,
(IF c.payortype = 'I' THEN c.payorname ELSE '' ENDIF) AS "Insurance"
FROM
sos.rv_charges a
JOIN sos.ptpayors b ON a.ptpayornum = b.ptpayornum
JOIN sos.payors c ON b.payornum = c.payornum
WHERE
trandate BETWEEN '2002-01-01' AND '2002-01-31'
AND a.provcode = '3'
ORDER BY
a.lastname, a.firstname, a.id