hi everyone,

I’m trying to do a simple calculation in my rails project. I would like

to find all rows in a table that match the given id of another table

(ie. comment_id) and has the value = 1 (“value” is a field in the

table), then add those values up. Next find the same rows with the

value = -1 and add those values up also. Finally, I would like to find

the total. Therefore, if there were 5 rows with value = 1, this would

be 5 and 3 rows with value = -1, this would be -3. Then when I add them

together, it would be totalvalue = 2.

Would somebody be able to help me with this? Or is there a better way to

do this? I’m not exactly sure where and how to setup this (do I do this

in the model or controller?).

Thanks!