扫码关注官方订阅号
小伙看你根骨奇佳,潜力无限,来学PHP伐。
select name from Employee where ManagerId !=null and salary>(select min(salary) from Employee where ManagerId =null); 这样写应该也可以。 可能我理解你的问题理解错了,我觉得我的语句的结果,和你的应该不一样!
select name from Employee t where t.ManagerId is NOT NULL AND exists ( select id from Employee a where a.id = t.ManagerId AND a.Salary < t.Salary )
感觉都差不多...
找最高的
select max(Salary),ManagerId from Employee where ManagerId is not null
找全部的,如果索引包含ManagerId 可以在后面加上 ManagerId is not null缩小范围
select * from Employee where Salary>(select max(Salary) from Employee where ManagerId is null)
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
select name from Employee where ManagerId !=null and salary>(select min(salary) from Employee where ManagerId =null);
这样写应该也可以。 可能我理解你的问题理解错了,我觉得我的语句的结果,和你的应该不一样!
感觉都差不多...
找最高的
找全部的,如果索引包含ManagerId 可以在后面加上 ManagerId is not null缩小范围