如何在SQL Serer中选择第4个最大Sailary [英] how to select 4th max sailary in sql serer

查看:68
本文介绍了如何在SQL Serer中选择第4个最大Sailary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在航行表中检索第4个最大航行表
如何告诉别人一个

how to retrive in a table 4th max sailary in a sailary table
how to do plese tell any one

推荐答案

尝试这个

try this

with aa as (
select top 4 * from testSalary
order by salary desc
)
select top 1 * from aa order by salary asc


select top 1 m.* from
(
    select top 4 o.* from
    (
        select top 4 * from [salary table]
        order by salary desc
    )o
    order by o.salary asc
)m


select * from (select ROW_NUMBER() OVER (ORDER BY sal desc) as srnumber, * from sailary ) as B
where srnumber = 4


这篇关于如何在SQL Serer中选择第4个最大Sailary的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆