I am struggling to write a performing query which would consist of the data from one subselect, and hierarchically retrieved data from another table based on the rows from t