How to make a query not group by page but keep showing the page name?

The task data come from multiple pages like below:

But when I try using advanced queries to list them by the deadline or schedule, it will separate a page into multiple independent tasks, and then the page name disappears.

I’m using this query:

#+BEGIN_QUERY
{:title ["📆 near TODOs (next 7 days, scheduled or deadline)"] 
     :query [:find (pull ?b [*])
          :in $ ?start ?next
          :where
          (or
            [?b :block/scheduled ?d]
            [?b :block/deadline ?d]
          )
          [(>= ?d ?start)]
          [(<= ?d ?next)]
  ]
  :result-transform (fn [result] (sort-by (juxt (fn [d] (get d :block/deadline) ) (fn [d] (get d :block/scheduled) ) ) result))
  :inputs [:today :7d-after]
  :collapsed? false}
#+END_QUERY

Actually, I’m not so familiar with the advanced queries syntax, the query code was just copied from another post, just for a test. But I would like to know if there is a possible way to show the page name on top of each task without grouping them by page.

1 Like

:result-transform removes breadcrumbs. I’ve asked about it here: Block level grouping is lost in query results

I have multiple pages that are separated into different subjects (Company 1, Company 2, etc…), and each subject contained the same headings (Section 1, Section 2, etc…). As you see in my screenshot, the tasks are under the heading “Section 3”.

Then, I want to create another new page and make an advanced query to list out all tasks in one place that sorting by deadline and schedule. But I met a problem when those tasks didn’t group by page, the subject names didn’t show with the tasks. And when there are only breadcrumbs showing the tag name, I can’t recognize where the tasks are from.

So, what I am asking is to show the subject name on top of each task. It means if the task is from “Company 1”, it should show “Company 1” on top of that task.

Not currently possible in that way.
Only option is to turn it into a table. It will then show page as a column.
Unfortunately that loses a lot of task functionality as well.