码迷,mamicode.com
首页 > 数据库 > 详细

在雇员表中查找第二高的工资SQL语句助记

时间:2015-07-05 22:36:26      阅读:374      评论:0      收藏:0      [点我收藏+]

标签:sql

        “在雇员表中查找第二高的工资的员工记录”SQL语句怎么写

        这个查询首先查找最高工资,然后将它从列表中排除,再查找最高工资。很明显,第二次返回的是第二高工资。

 

select top 1 * from employee where salary not int (select max(salary) from emplyee) order by salary desc

或者

select top 1 * from(select top 2 * from employee order by salary desc) as t order by salary asc

 

版权声明:本文为博主原创文章,未经博主允许不得转载。

在雇员表中查找第二高的工资SQL语句助记

标签:sql

原文地址:http://blog.csdn.net/xiaopangxia/article/details/46765961

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!