答案 0 :(得分:1)
如果您希望拥有多种不同货币的天数,则可以使用:
select fromid, toid, effdate, count(distinct exchangerate)
from t
group by fromid, toid, effdate
where count(distinct exchangerate) > 0;
答案 1 :(得分:0)
此查询将转置您的数据,对于您将从一行中的所有银行ExchangeRate
获得的每个日期:
select FromID, ToID, EffDate,
max(case when BankID = 1 then ExchangeRate end) AS ExRateBank1,
max(case when BankID = 2 then ExchangeRate end) AS ExRateBank2,
max(case when BankID = 3 then ExchangeRate end) AS ExRateBank3
from CurrencyExchange --assumed name, pleasy correct it if not correct
group by FromID, ToID, EffDate
如果您只想要费率不同的行,我建议您点击查询:
select * from (*)
where ExRateBank1 - ExRateBank2 != 0 or ExRateBank1 - ExRateBank3 != 0 or ExRateBank3 - ExRateBank2 != 0
代替*
,您粘贴上一个查询(作为子查询)。