...

问题描述 投票:0回答:1
I dont know what's your orders structure is but you should be able to solve it a similar way to this, just adjust to your conditions

bcur|curr | effectivedt|Expressinbase|rate
EUR |SAR  |01/04/2020  |1        |12.23
EUR |SAR  |01/05/2020  |1        |12.27 
EUR |SAR  |01/06/2020  |1        |12.29
EUR |INR  |01/04/2020  |1        |77.78
EUR |INR  |01/05/2020  |1        |77.90
EUR |USD  |01/04/2020  |1        |1.34
EUR |GBP  |01/04/2020  |1        |23
EUR |GBP  |01/05/2020  |1        |32
USD |SAR  |01/04/2020  |1        |45
USD |SAR  |01/05/2020  |1        |54
USD |GBP  |01/04/2020  |2        |0.83
INR |SAR  |01/04/2020  |1        |80
.
.

我有一个货币表,其结构如下,每个交易货币的汇率都是以参考货币即欧元为单位,但不一定是其他货币。

When transaction currency = the currency under consideration assign the amount accordingly
When transaction currency <> the currency then
    if the relation exists is currency table.
        If the rate is maintaied with Expressinbase = 1 then Amount in <curr> = Sales Order Amount / rate
        If the rate is maintaied with Expressinbase = 2 then Amount in <curr> = Sales Order Amount * rate
    If no direct relation is maintained (for USD or INR)
        Amount in <USD or INR> = Amount in EUR/ rate of EUR to <USD or INR>

我正在选择我的销售订单表中的一些金额,现在我需要根据销售订单表中的交易日期将交易货币的金额转换为欧元、美元和印度卢比。

这对逻辑相当有帮助,但我仍然停留在根据交易日期从货币表中只得到1条记录。

从汇率表隐式计算SQL中的汇率。
sql-server left-join currency-exchange-rates
1个回答
0
投票

我有一个货币表,其结构如下,其中每笔交易货币的汇率都是以参考货币(即欧元)为单位,但不一定是其他货币。

© www.soinside.com 2019 - 2024. All rights reserved.