我有以下疑问:
select
C.[Exchange Rate Amount]
from [Canada].[vCurrencyRate] as C
Where
C.[Currency Code] = 'CAD'
AND cast(C.Date as date) = cast( getdate() as date)
我希望它做的是,如果结果是0,那么有一天回滚日期
Where
C.[Currency Code] = 'CAD'
AND IF C.[Exchange Rate Amount] = 0 then cast(C.Date as date) = datediff( day, -1, cast( getdate() as date)) else cast(C.Date as date) = cast( getdate() as date)
但是我不知道怎么让它工作
1条答案
按热度按时间kxe2p93d1#
如果你想要一排,用
order by
限制为一行:因为方括号和
getdate()
,我假设这是sql server。其他数据库将使用limit
或者fetch first 1 row only
.