If you look at http://c2.com/cgi/wiki?QueryLanguageComparison you'll see that Datalog doesn't have the capability to perform aggregation, min, max, top N and such, due to the transitive relationships and recursive queries.
Essentially you'd have to do any aggregation etc in the application layer, which is far from ideal.
However, there is at least one product (which I must admit I haven't used or looked into detail) which extends the Datalog syntax for these cases: Datomic, look up the section "Aggregates Returning a Single Value".