About
This SQL shows all patients with nonzero patient or insurance credits. You can apply a filter in the dropdown to exclude whatever it is you don't want to see. It also includes patient name columns.
A sample image of this SQL report run in the Database Viewer is shown below:
Caveats
None.
Code
To highlight and copy the code below to your clipboard, simply click the Copy button.
select a.patno, fname, lname, ins_credit, pat_credit from (select patno, round(sum(ins_amount),2) as ins_credit, round(sum(pat_amount),2) as pat_credit from patient_credit_acct group by patno ) a left outer join register on a.patno = register.patno where (pat_credit >= 0.01 or pat_credit <=-0.01 or ins_credit >=0.01 or ins_credit <= -0.01)