Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 [Request]calculating the RANK automaticallly...

Author  Topic 

cool_moon
Starting Member

26 Posts

Posted - 2003-02-16 : 16:43:55
hi there,i request you for a SQL of the following case...i want to assign RANK of the student automatically by comparing it with the Marks_Obtain he/she got in the examination.....for e.g there are 5 student in a class
_____________________________________________________________________

Sr# Student_Name Total_Marks Marks_Obtain RANK(in class)
==== ============ =========== ============ ====
1) Tori 500 380 4
2) Nabil 500 460 2
3) Eve 500 427 3
4) Jeffery 500 300 5
5) RobVolk 500 490 1
_____________________________________________________________________

So in the above case when we assign the Marks_Obtain then the RANK should be calculated automatically,so that the person who have god the maximun Marks_Obtain will be RANK as 1 and so on.So,can you please help me in solving this query.I'll be Greatfull.take care.God Bless You All.




jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-02-16 : 16:54:28
Well, I'm a little upset because if Jeffery is me, then I have the lowest score ... and RobVolk the highest? no way !!

Here's one MS Access way to do this:

SELECT M1.[Sr#], M1.Student_Name, M1.Total_Marks, M1.Marks_Obtain, SUM(1) as Rank
FROM
Marks M1, Marks M2
WHERE M1.Marks_Obtain <= M2.Marks_Obtain
GROUP BY M1.[Sr#], M1.Student_Name, M1.Total_Marks, M1.Marks_Obtain

Do a query of this query to order the results by the rank.

- Jeff

Edited by - jsmith8858 on 02/16/2003 16:55:33
Go to Top of Page

cool_moon
Starting Member

26 Posts

Posted - 2003-02-17 : 12:58:51
Thanx Jeff.......the query you have send is working just fine and BTW .......from now on you will be listed as number 1 in my list... ;) ,take care and God Bless You All.

Go to Top of Page
   

- Advertisement -