Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 1 query (2 select statements, multiply value)

Author  Topic 

kitkit80
Starting Member

2 Posts

Posted - 2009-11-23 : 07:51:19
Hi,

I need to pull the (i)currency exchange rate(EUR) from currency table and (ii)sales amount(which is stored as EUR) from sales table matching the currency key referenced in both tables and then (iii)multiply both values to obtain the amount according to local currency (USD).

I am having an uphill battle figuring this out as it all has to be done within one query.

Anybody can share your expertise?

Thanks,

KITKIT80

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-23 : 08:16:31
It should be something like this

select s.sales_amout*e.exchage_rate from sales s inner join exchange_rate as e on s.curreny_id=e.currency_id

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kitkit80
Starting Member

2 Posts

Posted - 2009-11-23 : 08:21:12
Thanks Madhivanan,

I'll try it out! Cheers!
Go to Top of Page
   

- Advertisement -