Count By Group SQL Syntax

Dear all,

I'm trying to figure out how many rows I have for each group in the following query:

    @trails = Trail.find(:all,                          :select => "country",                          :group => "country")

How can I change this query to retrieve one column with the "country" list and one with a "count" column ?

Thank you,

Nick,

It is illegal in SQL to have count star and another col. So I tkink u
can't do it

The SQL line itself would be:

SELECT count(*), country FROM trails GROUP BY country;

So, it is perfectly legal.

I don't know how to do this in Rails though, but I can't imagine there not being a way...

--Michael

Is Trail.count :all, :group => 'country' what you want?

Fred

That's it! Thanks!