How to merge the results after sorting according to their parent block?”

Hi everyone. I am a new user.
I noticed that if I used a query without SORT-BY. The results will be merged by the common parent block like this:

The code is:

#+BEGIN_QUERY
{:title [:h1 "⌚️ next 10 days' deadline or schedule"]
  :query [:find (pull ?block [*])
          :in $ ?start ?next
          :where
          (or
            [?block :block/scheduled ?d]
            [?block :block/deadline ?d])
          [(> ?d ?start)]
          [(< ?d ?next)]]
  :inputs [:today :+10d]
  :collapsed? false}
#+END_QUERY

However if I used result-transform to sort the results. They will have the same parent block appearing many times.

The code is:

#+BEGIN_QUERY
{:title [:h1 "✅ Planned"]
 :query [:find (pull ?b [*])
 :where
   [?b :block/marker ?marker]
   [(contains? #{"TODO" "LATER"} ?marker)]  
   [?b :block/scheduled ?d]  
 ]
 :result-transform (fn [result] (sort-by (fn [r] (get-in r [:block/scheduled])) result)) ; sort the result by the scheduled date

}
#+END_QUERY

You can see many 203B in this picture. How to merge them? Thanks!

Welcome. Have you tried :group-by-page? ?

1 Like

That would just give their first result again.

@asuka unfortunately when the display is no longer grouped by page each block is displayed individually with its individual parent block. Even if that would repeat.

Currently sorting and grouping by page are incompatible :frowning:
You can use :breadcrumb-show? false if the parent block is not important to display.

1 Like

Hi. I think adding :group-by-page? true solved my question. Thank you all!