Get all tasks that link to a note (parent) and tasks that link to another note (child) that links to parent

What I’m trying to do

I am trying to query tasks that link to both a parent note and to its children. E.g., suppose there is a parent note [[Parent]] and a child note [[Child]] that links to the [[Parent]]. Basically, you can think of it as a task and a sub-task. “Note A” might look like

  • Do this on [[Parent]]

and “Note B” looks like

  • Do that on [[Child]]

I know how to get all the tasks that link to the [[Parent]] or that link to the [[Child]], but I cannot figure out how I can get the tasks that link to both (without explicitly specifying the names), and preferably group the output by whether it is a parent or a child, e.g,.

Note A

  • Do this on [[Parent]]

Note B

  • Do this on [[Child]]

Things I have tried

My starting point is this code

FROM [[]]
WHERE contains(text,
GROUP BY link as origin 
SORT origin.file.ctime DESC, text DESC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.