SQL Server SQL Query on Instructor table

ddhy6vgd  于 2023-04-28  发布在  其他
关注(0)|答案(2)|浏览(113)

I am stuck at the following SQL query:

Find the name of the departments having more than 12 instructors.

Ans should be given according to the given diagram.

uwopmtnx

uwopmtnx1#

Should be something like this:

select dept_name
     , count(ID)
  from instructor 
group by dept_name
having count(ID) > 12
m1m5dgzv

m1m5dgzv2#

use the group by and having clauses to filter on an aggregation function.

select d.dept_name
from department d
  inner join instructor i
    on i.dept_name = d.dept_name
group by d.dept_name
having count(*) > 12

相关问题