Liking cljdoc? Tell your friends :D

count-distinct

The count distinct aggregate function can be used to count the number of unique values for some expression over a group.

The below example counts the number of unique customers in the :Order table.

;; QUERY 
[[:from :Order]
 [:agg [] [:n-customers [rel/count-distinct :customer-id]]]]

;; STATE 
{:Order [{:customer-id 42, :order-id 0}, {:customer-id 42, :order-id 1}, {:customer-id 43, :order-id 2}]}

;; RESULT
[{:n-customers 2}]_

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close