1

我正在学习 MySQL,我正在尝试在查询中进行简单的算术运算,我正在尝试编写一个命令来确定Instructors大学中每个学院的人数 有人可以帮助我吗?谢谢!

下面是我的两张表:

    ________________________________________________________
    |    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 |
4

1 回答 1

1

接近这个的东西:

select department.faculty, count(professor.professor) as instructors from department join professor on department.department = professor.department group by department.faculty

基本上,您进行连接以“合并”这两个表,然后按教师对结果进行分组,并计算每个教师的教授人数。

于 2013-05-11T23:53:28.713 回答