This patch modifies the Calculations module to support multiple aggregate operations in one query. It also adds support for specifiying the column alias. This allows you to specify the column alias in the method call for use in an order by for example, without looking at the source to see how it generates the column alias.
min, max = Person.calculate(:min, :age, :max, :age)
opened, closed = Tickets.sum(:opened, :closed)
ordered_posts = Post.sum({:replies => 'post_replies'}, :order => 'post_replies')
This patch also adds ArgumentErrors for using :distinct on groups when using an adapter which doesn't support count(distinct). Before it would just error out silently.
Once (if) this patch is applied, I will work on adding multiple grouping column facilities in accordance with the SQL standard.
A full test suite is provided.