Results 1 to 1 of 1
Jul 26, 2008, 13:08 #1
- Join Date
- Jul 2008
- 0 Post(s)
- 0 Thread(s)
RoR SQL -> Ruby conversion problem
I'm having trouble getting the sum statement to work for the following query, I can get it to work in SQL like so:
SELECT sum( amount )
FROM expenses, budget_accounts
WHERE budget_account_id = budget_accounts.id
AND signup_id =1;
#Where signup_id would normally be the currently logged in user, not hard-coded 1.
But I can't figure out how to get this to work using RoR code.
What it's trying to do is sum up all the expense amounts for a particular user (budget_accounts.signup_id value). What makes it difficult is that the person can have more than one budget.
Thanks for your help!