# ActiveRecord find with expressions using fields

**URL:** <https://www.ruby-forum.com/t/activerecord-find-with-expressions-using-fields/145651>\
**Category:** Rails\
**Created:** [August 12, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/activerecord-find-with-expressions-using-fields/145651 "2008-08-12T16:07:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [August 12, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/activerecord-find-with-expressions-using-fields/145651/1 "2008-08-12T16:07:14Z")

</div>

Suppose I have a table with two fields “a” and “b” – both integers. I  
want to do:

select \* from mytable where a + b \> 18

I understand that I can pass :conditions a string but that has a few  
limitations. If I want more conditions have to either do a with\_scope  
or figure out the proper thing to append to the string my hand. It also  
has the limitation that I should not really say a or b, I should say  
“mytable”.“a” and “mytable”.“b”. (At least, that is what pops out of  
more find statements.) This particular example is for PostgreSQL and I  
worry that there are other syntax forms for different DBs.

Is there a “best” way to do this? Has this type of thing already been  
addressed?

Thanks,  
Perry
