We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
查找至少有 5 名直接下属的经理
5
create table employee ( id int, name varchar(255), department varchar(255), managerId int ); insert into employee values (101, 'John', 'A', null), (102, 'Dan', 'A', 101), (103, 'James', 'A', 101), (104, 'Amy', 'A', 101), (105, 'Anne', 'A', 101), (106, 'Ron', 'B', 101);
select name from employee where id in ( select managerId from employee group by managerId having count(managerId) >= 5 );
managerId
having
id
select managerId from employee group by managerId having count(managerId) >= 5
in
select name from employee, ( select managerId from employee group by managerId having count(managerId) >= 5 ) as temp where employee.id = temp.managerId;
employee.id = temp.managerId
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目
查找至少有
5
名直接下属的经理SQL:方法一
解析
managerId
分组,使用having
筛选出大于等于5
名下属的经理id
in
查出经理名字SQL:方法二
解析
managerId
分组,使用having
筛选出大于等于5
名下属的经理id
,作为临时表employee.id = temp.managerId
The text was updated successfully, but these errors were encountered: