How to convert activerecord result into a hash?

Viewed 6237

I have a query that returns results in ActiveRecord successfully.

select
    trunc(b.transaction_date) as transaction_date,
    sum(a.transaction_amount) as transaction_amount
from
  payment_transaction a,
  payment_settlement b
where
    a.transaction_status = 'S'
    and b.settlement_type = 'D'
    and trunc(b.transaction_date) > sysdate - 30
    and a.payment_transaction_id = b.payment_transaction_id
group by
    trunc(b.transaction_date)
order by
    trunc(b.transaction_date)

The above query returns 9 results.

What I want is to convert the entire result obtained above into a hash such as:

{
"01/01/16" => 764.00, 
"02/01/16" => 1508.00, 
"03/01/16" => 2000.00 
..
..
..
}

How can I achieve this?

2 Answers
Related