Say if there is a table with fields
Products
--------
ID
CategoryID
Name
Price
... etc
How can Ruby on Rails give a table that returns
select count(*) from products group by categoryID
which is to show how many products in each category? How will the result be like, as opposed to Products.find(:all)
which is an array of Product objects?
As a more advanced operation, how about
select count(*) from products p inner join category c on p.categoryID = c.ID
group by categoryID
and
select average(price) from products p inner join category c on p.categoryID = c.ID
group by categoryID
?