Open link in a new tab

Content

Expand project menu

SQL report question - determine parent

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?

Message actions

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