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 - 2 of 2 Answers

mummasani

  • Mar 7th, 2006
 

hi

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

enjoy

krian

  Was this answer useful?  Yes

shubhangig

  • 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

jmauriciovp

  • 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