This is the first post of a two-part blog series. Each of these case studies, the employee hierarchy and the [Bacon Numbers problem] , is a famous example of the use of the PostgreSQL recursive common table expression (CTE). Because [YugabyteDB re-uses the PostgreSQL SQL processing code]  “as is” , everything that I say in the present two-part blog post series applies in the same way to PostgreSQL as it does to YugabyteDB.

[ Using a recursive CTE to compute Bacon Numbers for actors listed in the IMDb]
All the code snippets and pictures in this post are copied from the YSQL documentation. The main page of the overall  [WITH] [** clause and common table expressions**] section explains that all the code is available in a downloadable code zip with a few master scripts to run all of the code mechanically.

#postgresql #recursive #cte

Using the PostgreSQL Recursive CTE – Part One
1.25 GEEK