Skip to content
Advertisement

Postgresql: more than one row returned by a subquery used as an expression?

I have a query to find the youngest generation in a family tree. This is my database

I need an output like below if result has more than one row

or if the result returns single row

This is my query:

How to fix this? And another question is there a way to get result using window funtion?

Advertisement

Answer

Calculate the generation as you recurse, and then get the rows that match the max(generation).

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement