<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PostgreSQL Interview &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/category/postgresql-interview/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 17 Nov 2016 18:06:43 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>PostgreSQL: Fibonacci Series Function for Database Developer Interview</title>
		<link>https://www.dbrnd.com/2016/11/postgresql-fibonacci-series-function-for-database-developer-interview-question-answer/</link>
					<comments>https://www.dbrnd.com/2016/11/postgresql-fibonacci-series-function-for-database-developer-interview-question-answer/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Tue, 15 Nov 2016 18:06:22 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[PostgreSQL Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Fibonacci Series Program]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3857</guid>

					<description><![CDATA[In this post, I am sharing one user define function to generate Fibonacci Series in PostgreSQL. Today Morning, I have started to take the interview for PostgreSQL Database Developer. Generally, I am asking complex SQL Query, but this time I have asked to implement few mathematical logics like: &#8220;Write a small function to generate Fibonacci [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&amp;linkname=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&amp;linkname=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&amp;linkname=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&amp;linkname=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&amp;linkname=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&amp;linkname=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F11%2Fpostgresql-fibonacci-series-function-for-database-developer-interview-question-answer%2F&#038;title=PostgreSQL%3A%20Fibonacci%20Series%20Function%20for%20Database%20Developer%20Interview" data-a2a-url="https://www.dbrnd.com/2016/11/postgresql-fibonacci-series-function-for-database-developer-interview-question-answer/" data-a2a-title="PostgreSQL: Fibonacci Series Function for Database Developer Interview"></a></p><p>In this post, I am sharing one user define function to generate Fibonacci Series in PostgreSQL. </p>
<p>Today Morning, I have started to take the interview for PostgreSQL Database Developer. </p>
<blockquote><p>Generally, I am asking complex SQL Query, but this time I have asked to implement few mathematical logics like: &#8220;Write a small function to generate Fibonacci Series&#8221;.<br />
Fibonacci Series means a series of numbers in which each number is the sum of the two preceding numbers.<br />
e.g 1, 1, 2, 3, 5, 8, 13&#8230;</p></blockquote>
<p>I am sharing this solution here, Database Developer should prepare yourself because Interviewer like, me can ask this kind of question.</p>
<p><strong>Fibonacci Series Function:</strong></p>
<pre class="crayon-plain-tag">CREATE OR REPLACE FUNCTION fn_Fibonacci(FNum INTEGER) 
RETURNS SETOF INTEGER
LANGUAGE SQL
AS $dbrnd$
WITH RECURSIVE cte(Num1,Num2) AS 
(
	VALUES(0,1)
	UNION ALL
        SELECT 
		GREATEST(Num1,Num2),Num1 + Num2 AS FibonacciSeries 
	FROM cte
        WHERE Num2 &lt; FNum
)
SELECT Num1 FROM cte;
$dbrnd$;</pre> </p>
<p><strong>Execute Function to generate Fibonacci Series upto 50:</strong></p>
<pre class="crayon-plain-tag">SELECT *FROM fn_Fibonacci(50);

 fn_fibonacci
--------------
            0
            1
            1
            2
            3
            5
            8
           13
           21
           34
(10 rows)</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/11/postgresql-fibonacci-series-function-for-database-developer-interview-question-answer/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
