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 builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close