all groups > sql server (alternate) > august 2006 >
You're in the

sql server (alternate)

group:

Calculating Positions Query Required...........


Calculating Positions Query Required........... --[zainy]--
8/31/2006 3:53:58 AM
sql server (alternate):
AA Guyz i want to calculate class position of students from a table.
Sample data is as follows...

Roll # - Name - Marks
1 - ABC - 60
2 - DEF - 60
3 - GHI - 57
4 - JKL - 55
5 -MNO - 50
6 -PQR - 53

The query should return the following result.

Roll # - Name - Marks - POSITION
1 - ABC - 60 - 1
2 - DEF - 60 - 1
3 - GHI - 57 - 3
4 - JKL - 55 - 4
5 -MNO - 50 - 5
6 -PQR - 53 - 6

I want query in MS SQL Server 2000
Re: Calculating Positions Query Required........... Ed Murphy
8/31/2006 12:47:55 PM
[quoted text, click to view]

Try the following:

select a.roll, a.name, a.marks, count(*) + 1 position
from table a
left join table b on b.marks > a.marks
AddThis Social Bookmark Button