Structuring composed SQL queries using Arel

I would like to make a composed query using several logical operators.

For example:
I have the following tables: orders, clients, products

I want to create the following statement:

AND:
  AND: Client name is equal to "Smith"
  AND: Client age equal or grater than 18
AND:
  OR: Order quantity more that 2
  OR:
     AND NOT: product material equal glass
     AND: product expire date greater than 2016

Having this statement, can you suggest me a way to construct this query in SQL using Arel?

My problem is how I can connect the AND and OR + AND NOT statement together.


Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.