获取第3个最高值的SQL查询 [英] sql query for getting the 3rd highest value

查看:161
本文介绍了获取第3个最高值的SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有table- student.which有字段studentid,studname,mark.i想要获得第三高分的学生姓名。行数不知道,我不知道是否需要计算,如果是,假设任何数字并给我答案。提前谢谢

解决方案



检查这个也

 选择 MAX(标记)来自 student 其中标记< 
选择 MAX(标记)来自学生其中标记<
选择 MAX(标记)来自学生))



最好的问候

M.Mitwalli


试试这个:

  SELECT  
TOP 1 标记
FROM
SELECT DISTINCT TOP 3 标记 FROM 学生 ORDER BY 标记 DESC )a ORDER BY 标记



或者这个

  WITH 结果 as  
SELECT Row_Number() over ORDER BY 标记 DESC as RN,* FROM student)
SELECT * FROM 学生 WHERE RN = 3


如何将答案应用于< a href =http://www.codeproject.com/Questions/410941/sql-query-to-find-2nd-maximum-salary> sql查询找到第二个最高工资 [ ^ ]?

i have table- student.which is having fields studentid,studname,mark.i want to get the student name who is having the 3rd highest mark.number of rows are not known,i dont know whether it is required for the calculation,if yes assume any number and give me the answer.thanks in advance

解决方案

Hi ,
Check this also

select MAX(marks) from student where marks <
(select MAX(marks) from student where marks <
(select MAX(marks) from student ))


Best Regards
M.Mitwalli


Try this:

SELECT
    TOP 1 marks
FROM
    (SELECT DISTINCT TOP 3 marks FROM student ORDER BY marks DESC) a ORDER BY marks


Or this one

WITH Results as
   (SELECT Row_Number() over (ORDER BY marks DESC) as RN,* FROM student)
SELECT * FROM student WHERE RN=3


How about applying the answers to sql query to find 2nd maximum salary[^]?


这篇关于获取第3个最高值的SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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