mySQL count frequency of one-many links -


suppose have 2 tables:

people ======= id name  jobs ===== id jobname person_id 

person may have many jobs.

i want count frequency of number of jobs people have. example 10 people have 0 jobs, 15 people have 1 job, 3 people have 2 jobs, 2 people have 3 jobs

i able count of number of jobs per person per:

select person.id, count(jobs.id) jobcount jobs person.id = jobs.person_id group person.id order trancount  personid   jobcount  1          1  2          1  3          2  ... 

but stuck @ summing these frequency.

can group them in outer select statement?

select jobcount, count(peoplecount) (   select person.id peoplecount, count(jobs.id) jobcount   jobs   person.id = jobs.person_id   group person.id ) frequency group jobcount 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -