Aggregate functions such as sum
, max
etc. are readily available in Datomic's Datalog implementation. They are written in the :find
clause in your query:
[:find (max ?date)
:where
...]
An aggregate function collects values from multiple datoms and returns
min
, max
, sum
, avg
, etc.(min n ?d)
(max n ?d)
(sample n ?e)
etc. where n
is an integer specifying the size of the collection.Given a collection of actors and (the now familiar) ratings data. Find the average rating for each actor. The query should return the actor name and the avg
rating.