All pastes #593950 Raw Edit

Untitled

public text v1 · immutable
#593950 ·published 2007-06-28 17:02 UTC
rendered paste body
select c.clientid,sum(p.amount),sum(cr.amount)
from clients c join payments p on p.clientid=c.clientid
join cred cr on c.clientid=cr.clientid 

where c.datestart < dateadd(dd,1,'03/31/07')
and p.description like '%monthly contrib%'
or p.description like '%monthly payment for acct%'
group by c.clientid
order by c.clientid