I have two tables jobs and users.
Users has a one-to-many relationship with jobs.
I want to segment users into groups of jobs_done. In other words, how many users did 1 job, 2 jobs, 3 jobs, etc The below query does that. However, I would like to lump together all users that have done 3 or more jobs into one group.
Here is the query I currently have
select
jobs_done,
count(1) as number_of_users
from ( select
u.id,
count(*) as jobs_done
from jobs j
JOIN users u on j.user_id = u.id
group by u.id ) a
group by jobs_done
Current Output:
times_used number_of_users
1 255
2 100
3 30
4 10
5 9
Desired Output:
times_used number_of_users
1 255
2 100
3+ 49
jobs_donebe recorded injobsfor the sameuser_idmore than once?