Aggregate in where clause


This one is for googlers

[:find ?tag ?n
 [(datomic.api/q (quote [:find ?e (count ?post) :where [?post :post/tag ?e]]) $) [[?tag ?n]]]
 [(> ?n 3)]]

RICH: You can do this and similar (SQL ‘HAVING’-like) things by chaining together queries, i.e. use the result of an aggregating query as the argument to a further narrowing query. source



Thanks for putting this here.
I’ve also often referred to this as nested query or sub-query