Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query Help....Using Exchange Rate.

Saumyadip Sarkar-OracleOct 30 2014 — edited Nov 14 2014

I have a table in which User Update some data which includes Currency and Month.

I have another table containing Exchange Rates month wise.

Now the problem is this exchange rate is populated only at the end of month. So for Sep-14 exchange rate, it will be uploaded say in 29th Sep-14.

Now if someone is entering data at the beginning of month say 1st Sep-14, the exchange is of Sep-14 is not available. So I want to make use of previous month Exchange Rate (latest available Exchange Rate) i.e Aug-14 till such time.

But once Sep-14 exchange is uploaded , I have to use Sep-14 exchange rate.

My Exchange Rate Table is shown below:

   

Currency_ToConversion_DateMonthConversion: TypeConversion_Rate
ARS29-Aug-14Aug--14Corporate3.73
ALL29-Aug-14Aug--14Corporate109.71
ALL29-Sep-14Sep--14Corporate109.75
ARS29-Sep-14Sep--14Corporate3.55

My USER Table:

  

Complex OrderAmountCurrencyMonth
11123ALLSep--14
22345ARSSep--14
33678ARSSep--14
44890ALLSep--14

I am using the following query. Though I am able to use the latest Exchange Rate, but not able to use for a particular month.

select ,sum(NVL(a.AMOUNT,0)/b.CONVERSION_RATE) AS "COMPLEX ORDER BOOKED"

from USER a, EXCHANGE_RATE b

WHERE b.CURRENCY_TO = a.CURRENCY AND  b.CONVERSION_DATE = (SELECT MAX(CONVERSION_DATE) FROM  CORPORATE_EXCHANGE_RATE))

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 12 2014
Added on Oct 30 2014
10 comments
2,876 views