Revision [51]
This is an old revision of PaymentsByProviderForTwoPeriods made by admin on 2008-10-24 12:49:10.Payments By Provider For Two Periods
Back to Query Directory
This query is interesting in that here we use correlated subqueries in the SELECT list to produce the subtotals for columns 2 and 3.
SELECT provcode, (select COALESCE(sum(crsplamt),0) from rv_creditsplits where providernum = a.providernum and credtype in ('cash','check','other') and dateapplied between '2000-01-01' and '2000-12-31') AS "Per 1 Payments", (select COALESCE(sum(crsplamt),0) from rv_creditsplits where providernum = a.providernum and credtype in ('cash','check','other') and dateapplied between '2001-01-01' and '2001-12-31') AS "Per 2 Payments" FROM providers a WHERE a.providernum > 100 and a.hiderow <> 1 ORDER BY provcode