I want to query by two columns added together like so, but I can seem to get it right:
Let’s say the database has two columns: a and b. I would like to query the coumns where a plus b is greater than 100.
SomeModel.select("(a + b) as c").where("c > ?", 100)
How would you go about doing that? This is in postgres.
I could just loop over each found column and add them together in rain but that seems inefficient.
This won’t help if you’re trying to limit the number of columns returned, and it won’t help to add a
some_model.cmethod, but try this if that’s okay: