I'm not sure why Arel complained about SQL in the SELECT clause (fields), but not the GROUP BY clause (key_fields). Maybe because it's not susceptible to user injection.
I'm also not sure why I couldn't use the aliases defined in SELECT in the GROUP BY clause, but hey this seems to work.