我有四个桌子
create table emp (emp_ss int, emp_name nvarchar(20));
create table comp(comp_name nvarchar(20), comp_address nvarchar(20));
create table works (emp_ss int, comp_name nvarchar(20));
create table supervises (spv_ss int, emp_ss int );
这里SUPRVISER_SS和EMP_SS是SS的子集。现在我必须找到:
我已经查询了上述问题,但不确定是否正确
SELECT COMP_NAME , COUNT(EMP_SS) FROM WORKS
WHERE EMP_SS IN (SELECT DISTINCT SPV_SS FROM supervises)
GROUP BY COMP_NAME
HAVING COUNT(EMP_SS) > 4;
员工人数最多的主管的姓名 但无法获得上述条件的要求结果
SELECT SPV_SS, COUNT(*) max_ FROM supervises GROUP BY SPV_SS
答案 0 :(得分:0)