codetalkertive
codetalkertive

Reputation: 21

Ruby on rails calculating total sum

id tithe offertory pledge Total
1 120 230 280 ???

I have a table like this and I want the total = tithe + offertory + pledge. how do I write a query for this?

Upvotes: 0

Views: 41

Answers (1)

Hackman
Hackman

Reputation: 1729

With the use of sum:

Record.where(id: 1).sum('tithe + offertory + pledge')

Upvotes: 1

Related Questions