We have moved to www.dataGenX.net, Keep Learning with us.

Monday, June 29, 2015

Get nth Highest or Lowest data from Table


Here, we are considering a table student and we need to find out Nth highest and lowest marks of a student.

Nth Highest

select * from student s1 where N-1 = ( select count(distinct(marks)) from student s2 where s1.marks > s2.marks)



Nth Lowest

select * from student s1 where N-1 = ( select count(distinct(marks)) from student s2 where s1.marks < s2.marks)



Like the Facebook Page & join Group
https://www.facebook.com/DataStage4you
https://www.facebook.com/groups/DataStage4you

https://twitter.com/datastage4you
https://groups.google.com/d/forum/datastage4you
For WHATSAPP group , drop a msg to 91-88-00-906098






No comments :

Post a Comment