---Fibonacci series in T-SQL
---Scnario 1
SELECT
FLOOR(POWER(( 1 + SQRT(5) ) / 2.0, number) / SQRT(5) + 0.5) AS fib_number
FROM master..spt_values
WHERE TYPE = 'p' AND number BETWEEN 1 AND 70
go
declare @Y int
declare @z int
declare @fib int
set @Y=1
set @z=1
set @fib=0
print @y
print @z
while @fib <2000
begin
set @fib= @Y +@z
print @fib
set @Y=@z
set @z=@fib
end
go
---Scnario 2
WITH fib(num,fib,fib2) as
(select 0 as expr1,0 as expr2,1 as expr3
union all
select num+1 as expr1,fib+fib2 as expr2,fib
from fib as fib_2
where (num<44)
)
select num,fib as fibonacci_number from fib as fib_1 where num>0
Subscribe to:
Post Comments (Atom)
Search This Blog
DAX - Grouping on multiple columns and the count
Please go thorugh the below URL for entire soultion. http://community.powerbi.com/t5/Desktop/DAX-Grouping-on-multiple-columns-and-the-cou...
-
We can filter an axis based on the members, or based on the measure value. Based on the members: begins with F or after Based on th...
-
Incremental Uploads: We have got a request to need a SSIS package to incremental uploads between two sql server instances which are two d...
-
Follow the below link https://blogs.msdn.microsoft.com/arvindsh/2013/04/23/cannot-resolve-the-collation-conflict-error-message-with-tem...
No comments:
Post a Comment