Click here to Skip to main content
13,096,268 members (52,002 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
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
Posted 26-Jun-12 17:00pm
Updated 8-Aug-17 20:30pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
sravani.v 27-Jun-12 0:08am
   
My 5! for first query
Prasad_Kulkarni 27-Jun-12 0:11am
   
Thank you Sravani!
glad to see you after long time..work load??
sravani.v 27-Jun-12 4:44am
   
No...searching for another job.
Prasad_Kulkarni 4-Jul-12 0:20am
   
Where?
Rahul Rajat Singh 27-Jun-12 3:01am
   
Nice. +5.
Prasad_Kulkarni 27-Jun-12 3:02am
   
Thank you Rahul!
subin joseph 27-Jun-12 6:50am
   
what does 'a' in this query stand for.is it any object
Sebastian T Xavier 28-Jun-12 0:35am
   
google about sql alias....
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

How about applying the answers to sql query to find 2nd maximum salary[^]?
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

SELECT marks FROM
(
SELECT
marks,
DENSE_RANK()over(order by marks desc)Dn1 FROM student
)as ff where dn1=3;

--this is the best query for finding multiple records exists for same marks.
  Permalink  
v2
Comments
Richard Deeming 9-Aug-17 11:44am
   
This question was asked, answered, and solved FIVE YEARS AGO.
santosh kumar pithani 10-Aug-17 6:00am
   
Let me know that which solution is best for getting particular rank record?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 9 Aug 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100