title: Combine 2 SELECTs into one SELECT in my RAILS application
body: <p>I have a table called ORDEREXECUTIONS that stores all orders that have been executed. It's a multi currency application hence the table has two columns CURRENCY1_ID and CURRENCY2_ID. </p>
  
  <p>To get a list of all orders for a specific currency pair (e.g. EUR/USD) I need to lines to get the totals:</p>
  
  <pre><code>v = Orderexecution.where("is_master=1 and currency1_id=? and currency2_id=? and created_at&gt;=?",c1,c2,Time.now()-24.hours).sum("quantity").to_d
  v+= Orderexecution.where("is_master=1 and currency1_id=? and currency2_id=? and created_at&gt;=?",c2,c1,Time.now()-24.hours).sum("unitprice*quantity").to_d
  </code></pre>
  
  <p>Note that my SUM() formula is different depending on the the sequence of the currencies.
  e.g. If I want the total ordered quantities of the currency pair USD it then executes (assuming currency ID for USD is 1 and EUR is 2.</p>
  
  <pre><code>v = Orderexecution.where("is_master=1 and currency1_id=? and currency2_id=? and created_at&gt;=?",1,2,Time.now()-24.hours).sum("quantity").to_d
  v+= Orderexecution.where("is_master=1 and currency1_id=? and currency2_id=? and created_at&gt;=?",2,1,Time.now()-24.hours).sum("unitprice*quantity").to_d
  </code></pre>
  
  <p>How do I write this in RoR so that it triggers only one single SQL statement to MySQL?</p>