SQL查询--列出薪资比“SMITH”多的所有员工

请先查看解决问题所需的数据表结构:点击跳转


问题:列出薪资比“SMITH”多的所有员工


答案:

解法一:

select * from emp where sal>(select sal from emp where ename='SMITH');


解法二:

select * from emp A where exists(select null from emp B where B.sal<A.sal and b.ename='SMITH');


解法三:

select * from emp A,(select sal as salary from emp where ename='SMITH') B where A.sal>B.salary;


你可能感兴趣的:(SQL查询--列出薪资比“SMITH”多的所有员工)