[Answer]-Django query: Get states sorted by employee count

1👍

solved it:

OfficeModel.objects.values('state').annotate(employee_cnt=Count('employee_office')).order_by('-employee_cnt')

Hope it helps others!

Leave a comment