SUM with two intervals in mysql
Using case we can pass the conditions to get sum with different intervals.
Following code will give you the sum of paid with two different intervals.
sum(case when (paymentDate between '2013-12-01' and '2014-04-08') then paid else 0 end) paid1,
sum(case when (paymentDate between '2012-12-01' and '2013-04-08') then paid else 0 end) paid2
from transaction,user where user.id=transaction.uid
and transaction.paid>0 and email like '%%'
and name like '%%' group by uid order by paid1,paid2