Fibonacci in SQL? | Easy SQL Problem

Published: 10 February 2025
on channel: Write a SQL Query
74
6

In this video we write a SQL query to generate the first N Fibonacci numbers. Along the way, we review the basics of recursive SQL queries.

Video chapters
00:00 - Problem description and set-up
02:12 - Review of recursive SQL queries
05:48 - Recursively generating the first N integers
07:15 - Differences between first N integers and first N Fibonacci numbers
09:26 - Writing the Fibonacci query
15:53 - Postscript: Binet's formula
17:15 - Outro

If you would like to follow along at home and have a crack at solving this problem:
Local environment set-up instructions are in the Write a SQL Query GitHub repo README: https://github.com/cedwards036/write-...
The problem set-up code for today's episode can be found here: https://github.com/cedwards036/write-...

Thumbnail art and channel logo: FriezerBurnt https://www.friezerburnt.com/

Recording set up:
Database: PostgreSQL run locally in a docker container
SQL client: DBeaver https://dbeaver.io/
Microphone: Samson Q2U https://samsontech.com/products/micro...
Recording software: OBS https://obsproject.com/

Thank you for watching! Leave a comment below if you can think of any alternate solutions to today's problem, have suggestions for future videos, or just like to chat. Happy querying!


On this page of the site you can watch the video online Fibonacci in SQL? | Easy SQL Problem with a duration of hours minute second in good quality, which was uploaded by the user Write a SQL Query 10 February 2025, share the link with friends and acquaintances, this video has already been watched 74 times on youtube and it was liked by 6 viewers. Enjoy your viewing!