sql求S=1+1⼀2*2+1⼀3*3......+1⼀100*100

快点 求救!
2024-11-10 15:37:46
推荐回答(2个)
回答1:

declare @S float,@I int
set @I=1
set @S=0
while @I<=100
begin
set @S=@S+1.0/(@I*@I)
set @I=@I+1
end
print @S

回答2:

;with temp as
(select cast(1 as float) as lvl, cast (0.0000 as float) as num
union all
select lvl+1,1/(lvl*lvl)
from temp
where lvl<=100
)
select sum(num) from temp
---里面是有括号的吧?1/(3*3)?