通过SQL CTE计算Fibonacci

通过SqlServer的Common Table Expressions (CTE)可以进行递归计算。

参见Using Common Table ExpressionsRecursive Queries Using Common Table Expressions

通过CTE计算Fibonacci

  
    
WITH Fib(a, b)
AS (
SELECT 0 , 1
UNION all
SELECT b, a + b
FROM Fib
WHERE b < 10
)
SELECT * FROM Fib

你可能感兴趣的:(fibonacci)