views:

31

answers:

1

Using Rails 3.0, i'm trying to do a count on number of times a each combination of column1 and column2 occur.

IE Column A has values A-Z and Column B has values 1-5, i want a count of A1, A2, etc.

Is there a way to either group by multiple columns or join the two columns and group of the result? In reading the documentation, it wasn't clear how to accomplish this.

A: 

You should be able to specify multiple attributes to group by. Something like:

MyClass.count(:all, :group => 'column1, column2')
Shadwell