通过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

posted @ 2011-03-02 16:48  dragonpig  阅读(292)  评论(0编辑  收藏  举报