兔子数列

With A(B,C,D,E)
As
(
Select 1 As B,1 As C,0 As D,1 As E
Union All
Select B+C As B,C,1 As D,E As E From A Where E<40 And D=0
Union All
Select C As B,B+C As C,0 As D,E+1 As E From A Where E<40 And D=0
)
Select B From A Where D=0

 

你可能感兴趣的:(SQL,Server)