title: SQL : Currency Conversion from given currency to destination currency
body: <p><a href="https://i.stack.imgur.com/I0H77.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I0H77.jpg" alt="enter image description here"></a></p>
  
  <p>I have two tables, Table1 with amount , amountCurrency and destination currency and Table2 have the conversion rate(As mentioned in image conversation rate are in terms of USD) .   </p>
  
  <p><strong>What I want to do :</strong>   </p>
  
  <p>Convert Amount from amountCurrency to destination currency and update it in last column of Table1  </p>
  
  <p>Example : Amount in row one of Table1 is in INR and I want to convert it to CAD. As per math I will get conversation rate for 1 INR on given conversion_date from Table2 multiple it by AmountCurrency. something like,    </p>
  
  <pre><code>select Rate from Table1 where converstion_Date = '2014-06-30' and Currency = 'INR'.
  </code></pre>
  
  <p>Above query will give me 0.0160752000 and we will convert INR TO USD i.e
   100 * 0.0160752000 = 1.60752 USD<br>
  Since we want to convert it to CAD get conversion rate for 1 CAD on given conversion_date, 1 CAD = 0.9399380000 USD, now we need to convert 1.60752 USD to CAD that can be done by dividing it with CAD rate i.e 1.60752/1.60752 = 1.71024 CAD.       </p>
  
  <p>My Table1 has around 10000 rows and Table2 has conversion rate for all the currencies for all dates till now. What is the best way to iterate Table1 rows and do the conversion and update it in <strong>CalculateAmountInDestinationCurrency</strong> column.   </p>
  
  <p>I was thinking to have a loop like,   </p>
  
  <pre><code>While (Select Count(*) From Table1) &gt; 0
  begin
  
  // step1 : Get top row   
  
  //step2 : Get conversition rate for  **Amountcurrency** using select query to table2   
  
  //step3 : Multiply with amount (Here we have USD value for amount)    
  
  //step4: Get conversion rate for **DestinationCurrency**   
  
  //step5: Divide USD Amount with result from step 4    
  
  //Update   
  
  end
  </code></pre>
  
  <p>Any help is appreciated. Is this good way to do this? Is there any better way? </p>