在有大量数据时 少用In(数据会丢失) 用left join 代替

select @From,
@To,
EffectiveDate,
GETDATE(),
Rate
from Config_Currency_ExchangeRate_Temp
where EffectiveDate not in (
select EffectiveDate
from Config_Currency_ExchangeRate
where EffectiveDate >=@BeginTime and
EffectiveDate <=@EndTime and
CIDFrom = @From and
CIDTo = @To
)
and EffectiveDate >=@BeginTime
and EffectiveDate <=@EndTime
and CIDFrom = @From
and CIDTo = @To
---------------------------------------------
---------------------------------------------
这种写法可以改为
select @From,
@To,
t.EffectiveDate,
GETDATE(),
t.Rate
from Config_Currency_ExchangeRate_Temp as t left join Config_Currency_ExchangeRate as r on t.EffectiveDate = r.EffectiveDate and t.CIDFrom = r.CIDFrom and t.CIDTo = r.CIDTo
where r.ID is null
and EffectiveDate >=@BeginTime
and EffectiveDate <=@EndTime
and CIDFrom = @From
and CIDTo = @To

上一篇:软件理论基础—— 第一章命题逻辑系统L


下一篇:浅谈AndroidGPU过度绘制、GPU呈现模式分析及相关优化