This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
select a.msisdn,sum(b.amount) 'amount'
from account a
inner join accrued_Transaction b on a.msisdn = b.msisdn
where a.account_group = 300 and a.opt_in_date is null and b.year <= 2010
AND b.quarter <= 2 AND (b.opted_in is null OR b.opted_in = 1)
GROUP BY b.msisdn, a.msisdn