Open hu0514 opened 1 year ago
select count() from (select count() as count_1 from group GROUP BY user_id) tmp where count_1 > 300
How to write this in tortoise
await Group.annotate(count_1=Count('user_id')).group_by('user_id').filter(count_1__gt=300).values('user_id', 'count_1') # [{'user_id': 1, 'count_1': 301}, ...]
select count() from (select count() as count_1 from group GROUP BY user_id) tmp where count_1 > 300
How to write this in tortoise