Total Credits without Sort Codes, by Primary Provider

SELECT
 r.provcode,
 r.provlname,
 SUM(j.amount)
FROM
 sos.journal j
 JOIN sos.patients p on j.ptnum=p.ptnum
 JOIN sos.providers r on p.providernum=r.providernum
WHERE
 j.trandate BETWEEN '2000-03-01' AND '2016-03-15' AND
 j.sortcode IS NULL
GROUP BY
 r.provcode, r.provlnamee

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.