How to check for the presence of a tag outside any tasks in that note?

What I’m trying to do

When I tag a task with a tag, say #project1, then the note that holds the task inherits that tag.

Given that, how do I query for all notes tagged #project1 outside of any task?

Things I have tried

This is the closest I managed to get to what I want:

TABLE without ID
  filter(file.etags, (x) => contains(x,"#project1")) AS tag, AS Note
FROM #project1
WHERE !any(file.tasks.tags, (t) => contains(t,"#project1"))
SORT filter(file.etags, (x) => contains(x,"#project1"))

The problem with this query is that it merely excludes any notes that have the #project1-tag in a task, even though the tag might also be present outside a task.

Is there any way of checking for the presence of a tag outside the tasks?

Note: The query obviously does some more stuff unrelated to this question, so for anybody wondering: It gives me all notes tagged with #project one (and without any task tagged with #project1), and sorts them based on the tag hierarchy, and it also removes all irrelevant tags from the tag column.

As a side question: the query looks a bit redundant to me, with almost the same operation (contains()) being performed three times. Is there any way of improving the query in that respect?

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