Content
SQL report question - determine parent
Started July 20, 2021 20:05 · 1 reply · 2 participants
I'm trying to develop a report directly from the "openproject" Postgresql database for workpackages. How should I determine the parent workpackage for a particular workpackage in SQL?
Hi Mike,
The parent of a work package as all other relations are modeled through the relations table as a direct acyclic graph
To get the immediate parent, use this SQL:
SELECT * FROM relations WHERE to_id = <ID of the child> AND hierarchy = 1
Best
Oliver