I have student table with fields name,marks1,marks2,marks3 fileds. i want the output as the student details and thier totals and their rank in class, i.e calculated at runtime.please send me the query in sql server or oracle

Showing Answers 1 - 3 of 3 Answers


  • Mar 7th, 2006


i had done in my own way. check it whether there should be another easiest one or not

i had created a view (rank) first  with a query

create view rank as select sname , marks1+marks2+marks3 total from student order by total desc;

and then

select sname, total, rownum from rank;

here rank is view name

rownum gives the rank



  Was this answer useful?  Yes


  • Mar 24th, 2006

Try this query for ranking

select s.studentname,count(b.studentname)

from studenttable s, studenttable b

where s.totalmarks<=b.totalmarks

groupby s.studentname;

  Was this answer useful?  Yes


  • Dec 17th, 2008

select row_number() over (order by a.marks1+a.marks2+a.marks3 desc) as Ranking, a.sName, a.marks1+a.marks2+a.marks3 total, a.marks1, a.marks2, a.marks3

from students a

order by total desc

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions