I have a table that looks like so:
| user_id | client_application_id | invalidated_at
| 1 | 55555 | |
| 1 | 123 | |
I want to be able to do one thing:
- Be able to count how many user_id's have more than 250 client_application_id's on their account and order it so that it starts at 250 and goes up.
My current (incorrect)query looks like so:
select user_id, count(user_id) as cnt from tokens where invalidated_at is null group by user_id having count(user_id) > 250 order by cnt ;
The output looks like so:
user_id | cnt
------------+-----
1 | 251
5 | 251
Using this example, I would like the query to count the two users that have 251, so it would look like so:
Count_Of_Users | Application_Count
2 | 251