select
    extract(year from created_at) || 
    'Q' || 
    extract(quarter from created_at) as quarter,
    actual_or_reserve,
    payment_or_recovery,
    sum(amount) as total_amount
from
    transaction
where
    created_at >= '2015-04-01'
group by
    quarter,
    actual_or_reserve,
    payment_or_recovery;
