Need help with complex querry

Ah no :sweat_smile: sorry I hadn’t gotten back yet.
I had tried asking someone else, but hadn’t heard back yet.

But yeah the problem is that I can’t get the two step part to work.
I can definitely do two queries though!

Here’s what I was at :joy: I could combine everything with everything, but I couldn’t grab the result I needed from the result set. My clojure knowledge and expertise is too limited.

So here’s how to do it with 2 queries.

First query

#+BEGIN_QUERY
{:title [:b "last meeting"]
 :query [:find (max ?day)
  :where
   [?a :block/name "buildingassoc"]
   [?m :block/refs ?a]
   [?m :block/content ?c]
   [(clojure.string/includes? ?c "Meeting")]
   [?m :block/page ?j]
   [?j :block/journal-day ?day]
 ]
}
#+END_QUERY

Second query

#+BEGIN_QUERY
{:title [:b "past notes"]
 :query [:find (pull ?b [*])
  :in $ ?parent
  :where
   [?parent :block/refs ?j]
   [?a :block/name "buildingassoc"]
   [?d :block/name "tobediscussed"]
   [?b :block/refs ?a]
   [?b :block/refs ?d]
   [?b :block/page ?p]
   [?p :block/journal-day ?noteday]
   [?j :block/journal-day ?meetday]
   [(> ?noteday ?meetday)]
 ]
 :result-transform (fn [r] (sort r))
 :inputs [:parent-block]
}
#+END_QUERY

(Remove the result-transform if you need to group your results by page)

1 Like