I have the following table
Employee
Fields are
- id
- annual_leave_total
- group_id (FK)
And I writing a simple sum group by query by stating getting a sum of annual_leave_totals grouped by group_id ie
Employee.select("department_id, sum(annual_leave_total)").group(:group_id)
But what I get instead in the console is the following
irb(main):010:0> Employee.select("group_id, sum(annual_leave_total)").group(:group_id)
Employee Load (1.0ms) SELECT group_id, sum(annual_leave_total) FROM "employees" GROUP BY group_id
=> #<ActiveRecord::Relation [#<Employee id: nil, group_id: 1>, #<Employee id: nil, group_id: 2>, #<Employee id: nil, group_id: 3>]>
Why is it returning this hash type of result? It's different to what expected in an actual sql query...
Any ideas?