Find :select sort on calculated value

I have a table ‘posts’ , each record has 2 fields ‘post_count’ and
‘post_value’

I would like to find all records, sorted on the calculated ratio value:
‘post_value’ / ‘post_count’

I am using MySQL 5 so I could use a stored procedure, but how can I sort
on the calculated value ,

can I write something like :

Post.find( :all, :select => [‘post_count’, ‘post_value’,
?calculated_value?], :order => ?calculated_value?)

thanks for your suggestions

kad

On Oct 30, 2007, at 6:58 PM, Kad K. wrote:

can I write something like :

Post.find( :all, :select => [‘post_count’, ‘post_value’,
?calculated_value?], :order => ?calculated_value?)

thanks for your suggestions

kad

Yes, almost exactly like that:

Post.find(:all, :order => ‘post_value/post_count’)

-Rob

Rob B. http://agileconsultingllc.com
[email protected]