Application (:id, :name)
has_many :steps
Step (:id, application_id, :status)
Sample data:
Application Name
------------- ------------
1 'Peter'
2 'Paul'
3 'Mary'
Step Application ID Status
------ -------------- -------------
1 1 'new'
2 2 'new'
3 1 'in-review'
4 2 'in-review'
5 2 'completed'
6 3 'new'
7 3 'in-review'
How can I get a report of count(*) of lastest statuses of applications? i.e.
Status Count
------------- -------
'in-review' 2
'completed' 1
HAVING, MAX do not seem to be working with mysql 5.1
This one seems to be working
You can use this in Step.find_by_sql