Sum multiple columns individually

You're getting back an array. Try x[0].amt1 for example.

Using find(:first) or find(:all) is incorrect here since technically you're not retrieving a model. You're retrieving aggregated data from the db. It'd be nice to add support for multiple values to ActiveRecord::Calculations, but I can't envision a decent API that doesn't look hackish. Your best bet is to use connection.select_all or select_values

# returns array of values, like [1, 5] def sum_amounts   connection.select_values("SELECT sum(amt1), sum(amt2) ...") end

or..

# select_all returns an array, but since it's an aggregation, it should only return 1 row. # Calling #first returns a hash like { 'amt1' => 1, 'amt2' => 5 } def sum_amounts   connection.select_all("SELECT sum(amt1), sum(amt2) ...").first end