title: currency conversion when direct mapping is not provided
body: <p>I have two tables @tbl_curr_master and @tbl_curr_trans b</p>
  
  <p>I @tbl_curr_master, I have master data from each currency to some other currency with a conversion rate of the source to target currency. </p>
  
  <p>the second table, @tbl_curr_trans i have some amount of each currency and I want to convert all the amount to EUR only in some cases mapping is provided directly 
  where I can join directly on the basis of a.curr_name=b.from_curr and can get required data but in some cases where direct mapping is not provided 
  like in INR to EUR there is no such direct mapping but what I can do is I can first compute USD and then compute EUR.</p>
  
  <p>Please suggest how can I do it in an efficient manner in tsql query. </p>
  
  <pre><code>declare @tbl_curr_master table (id int  ,from_curr char(5), to_curr char(5),conversion_rate float )
  
  insert into @tbl_curr_master(id, from_curr,to_curr,conversion_rate)
  values(1,'usd','eur',0.28999),(2,'inr','usd',2.3645),(3,'chk','eur',0.56977),(4,'chk','eur',0.56977)
  
  
  declare @tbl_curr_trans table (id int , curr_name varchar(5), amount float)
  
  insert into @tbl_curr_trans (id,curr_name, amount)
  values(1,'inr',789000),(2,'usd',896666),(3,'chk',458888)
  
  
  select a.id , a.curr_name ,b.to_curr,  a.amount/ b.conversion_rate
  from @tbl_curr_trans a , @tbl_curr_master b 
  where a.curr_name=b.from_curr  
  </code></pre>