Sorting by date, prio etc. in advanced queries removes grouping by page. Is there a way to add it back, or to insert link to original block next to each result. This is sometimes useful for context for e.g. a task.
Based on this: Separate query result sorting logic from result transform and other stuff linked there this might not be possible.
One of the default queries can be an example
#+BEGIN_QUERY
{:title "🔨 NOW"
:query [:find (pull ?h [*])
:in $ ?start ?today
:where
[?h :block/marker ?marker]
[(contains? #{"NOW" "DOING"} ?marker)]
[?h :block/page ?p]
[?p :block/journal? true]
[?p :block/journal-day ?d]
[(>= ?d ?start)]
[(<= ?d ?today)]]
:inputs [:14d :today]
:result-transform (fn [result]
(sort-by (fn [h]
(get h :block/priority "Z")) result))
:collapsed? false}
#+END_QUERY