from django.db.models import Count, Q q2 = Exam.objects.aggregate( success=Count("pk", filter=Q(score__gte=85)), ) print(q) # {"success": 5}