Skip to content

use uniq for select #113

Answered by jayvynl
amin-basiri asked this question in Q&A
Discussion options

You must be logged in to vote
from clickhouse_backend.models import uniq
from django.db.models import Count

Analytics.objects.annotate(uniq_aid=uniq("aid"))

# You can try this
Analytics.objects.aggregate(count=Count(uniq("aid")))
# This may also work
Analytics.objects.aggregate(count=Count("aid", distinct=True))

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amin-basiri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants