Assuming:
- you talk about tasks on those pages, not tasks referencing those pages
- you don’t want to exclude top level namespaces
You can use this advanced query:
#+BEGIN_QUERY
{:title [:h3 "Tasks without namespace"]
:query [:find (pull ?b [*])
:where
[?b :block/marker ?marker]
[(contains? #{"TODO" "DOING"} ?marker)]
[?b :block/page ?p]
(not [?p :block/namespace])
]
}
#+END_QUERY
If you need something more specific, let me know.