title: sql query to fetch exchange rate
body: <p>Given a sales table with sales amount stored in local currencies and an exchange rate table containing currency conversion rate, to get total sales amount in USD for each sales date I need query </p>
  
  <p>Sales Table:</p>
  
  <pre><code>Sales Date  Sales Amount    Currency       
  01-JAN-16            500    INR    
  01-JAN-16            100    GBP    
  02-JAN-16           1000    INR    
  02-JAN-16            150    GBP    
  03-JAN-16           1500    INR  
  </code></pre>
  
  <p>Exchange Rate Table:</p>
  
  <pre><code>Source Currency  Target Currency  Exchange Rate  Effective Start Date
  INR              USD                      0.014  31-DEC-15     
  INR              USD                      0.015  02-JAN-16     
  GBP              USD                       1.32  20-DEC-15     
  GBP              USD                       1.30  01-JAN-16     
  GBP              USD                       1.35  10-JAN-16   
  </code></pre>
  
  <p>have no idea how I should proceed </p>
  
  <p>I have to do two things match the currency and then check for the same date exchange rate or before sales_date</p>