SQL函数问题 [英] SQL Function problem
本文介绍了SQL函数问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
declare @diff float
set @diff=0.8
if (@diff>=0.0) and (@diff<0.3)
begin
set @diff=0.0
print 'a'
end
else
if (@diff>=0.3) and (@diff<0.8)
begin
set @diff=0.5
print 'b'
end
if @diff >= 0.8
begin
set @diff=1.0
print 'c'
end
print @diff
-------------------------------------------------- -
----------------------------------------------------
declare @monthdays float
declare @lgwdays int --legalworkingdays
declare @lgpdays float --legalpresentworkingdays
declare @diff float
set @diff=0
set @monthdays=day(dateadd(mm,datediff(mm,-1,'30-09-2011'),-1))
set @lgwdays=@monthdays-4
set @lgpdays=(9/@monthdays)*@lgwdays
set @diff=round(@lgpdays,2)-floor(@lgpdays)
print @diff
if (@diff>=0.0) and (@diff<0.3)
begin
set @diff=0.0
print 'a'
end
if (@diff>=0.3) and (@diff<0.8)
begin
set @diff=0.5
print 'b'
end
if (@diff>=0.8)
begin
set @diff=1.0
print 'c'
end
print @diff
------------为什么上述两个函数的输出具有相同的值
------------why the output is different for above 2 functions with same values
推荐答案
可能是因为它们包含不同的逻辑.
顶部的条件是else
,底部的条件是else
.
Probably because they contain different logic.
The top one has anelse
condition the bottom one lacks.
这篇关于SQL函数问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文