我一直想寫一個case語句如下SQL Server - 爲什麼calc給0?
case when datediff(week,cast(cast(tourney_date as char(8)) as date, current_timestamp) >104 then 0
when datediff(week,cast(cast(tourney_date as char(8)) as date, current_timestamp) <=13 then 1
when datediff(week,cast(cast(tourney_date as char(8)) as date, current_timestamp) between 14 and 104
then cast(((datediff(week,cast(cast(tourney_date as char(8)) as date, current_timestamp)-13)/91) as numeric(6,5) end as multiplier
但是這不會返回非0.0000值時,DATEDIFF返回14和104之間的值來測試這一點,我試圖讓一個真正的基本測試上班
declare @test as numeric(6,5)
set @test=72/91
print @test
我還是得到0.00000?我正在犯什麼小錯誤?
在此先感謝。
嘗試這個代替 聲明@test爲數字(6 ,5) set @ test = 72.0/91.0 – Harry
謝謝解釋測試,但任何想法爲什麼案件不起作用? – thequadge