SQL - Count per Person -


using mysql
lets have records in table columns:
personname, projecttype

personname contains names of people. projecttype contains types of projects, i.e. software, mechanical, etc.

goal:

i want select table number of projects per person. need both number of projects total, , number of projects per type.

how write sql this?

  1. number of total projects, per person
  2. number of projects per projecttype, per person

i want able data in personname, #ofprojects format.

i tried looking @ similar questions/answers, im not quite getting information want them.

number of total projects, per person

select   person, count(*) totalprojectsperperson   table group person 

number of projects per projecttype, per person

select   person, projecttype, count(*) totalprojectspertypeperperson   table group person, projecttype 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -