Reputation: 899
I am learning MySQL and I am trying to make simple arithmetic in the query,
I am trying to write a command that would determine the number of Instructors
in each Faculty in the university
Can anyone help me in this? Thank you!
Here below are my two tables:
________________________________________________________
| Department | Faculty | Building |
--------------------------------------------------------
| Humanities | Arts and Sciences | Chardon |
| English | Arts and Sciences | Chardon |
| Mathematics | Arts and Sciences | Monzon |
| General Engineering | Engineering | Stefani |
| Agronomy | Agriculture | Pinero |
_________________________________________________________________________
| Professor | Department | Rank | Salary |
---------------------------------------------------------------------------
| Joe Blow | Biology | Professor | $73,500.00 |
| Sam Snow | Mathematics | Instructor | $45,700.00 |
| George Grow | Electrical Engineering | Associate Professor | $69,250.00 |
| Hiram Lowe | English | Assistant Professor | $63,750.00 |
Upvotes: 1
Views: 52
Reputation: 2393
Something close to this:
select department.faculty, count(professor.professor) as instructors from department join professor on department.department = professor.department group by department.faculty
Basically you do a join to "merge" the two tables, then group results by faculty, and count professors for each faculty.
Upvotes: 1