如何使用SQL Query从学生表中选择第二个最高标记 [英] how to select second heighest mark from a student table using SQL Query

查看:94
本文介绍了如何使用SQL Query从学生表中选择第二个最高标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用SQL查询从表中选择第二个最高值



表名是Student,字段是

StudentID(主键)

名称nvarchar(50),

地址nvarchar(50),

mark nvarchar(50)

how to select second heighest value from a table using SQL Query

the table name is Student, the fields are
StudentID( Primarykey)
Name nvarchar(50),
address nvarchar(50),
mark nvarchar(50)

推荐答案

我们不是来为你做功课。如果你正在努力,那就问你的导师。
We're not here to do your homework for you. If you're struggling then ask your tutors.


让我们谈谈现实生活中的类似问题,例如找到班上第二高的学生,一种方法是:

1.将它们从最高到最短从左到右排列( ORDER BY [ ^ ])

2.选择第一个左起两个( TOP [ ^ ])。

3.较短的( MIN() [ ^ ]这两个是你的答案。
Let relate to similar problems in real life, for example finding the second tallest students in the class, one way is:
1. Line them up from tallest to the shortest from left to right (ORDER BY[^])
2. Select the first two from the left (TOP[^]).
3. The shorter (MIN()[^]) of these two is your answer.


当排除真正的最高分时,第二个最高分是最高分......

The second highest mark is the highest mark when the true highest mark excluded...
SELECT MAX(mark) FROM Student WHERE mark <> (SELECT MAX(mark) FROM Student)



想一想......


Think about it...


这篇关于如何使用SQL Query从学生表中选择第二个最高标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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