lundi 5 octobre 2015

retrieve records by ascending order with multiple conditions

I need to get the largest of 3 amount fields from my table. But there are 2 amount fields in the Transaction table named expense_amt and income_amt. I need to get the largest of 3 amount fields by looking on both fields. I understand that I can query with multiple fields like

Model.order('expense_amt', 'income_amt').limit(3)

But this does not return largest of 3 amount fields as i expected. So basically i need to retrieve largest of 3 transactions.

Aucun commentaire:

Enregistrer un commentaire