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

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

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

  Print Answers RSS
0 OriginalGriff 530
1 jyo.net 484
2 DamithSL 353
3 Afzaal Ahmad Zeeshan 253
4 Sergey Alexandrovich Kryukov 230
0 OriginalGriff 795
1 DamithSL 611
2 Mika Wendelius 494
3 jyo.net 484
4 Afzaal Ahmad Zeeshan 404


Advertise | Privacy | Mobile
Web03 | 2.8.150731.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2015
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