You must Sign In to post a response.
  • Category: ASP.NET

    Query problem

    hi
    i hv a table in which i hv total marks & % of stodents subject wise...
    i want to give ranks to each student...as
    student with heighset total get 1 nd so on
    nd if two stu hv same total mks they gat same rank like 3
    nd student below these two student get rank 5 inspite of 4

    how to write query or any solution for this
  • #344766
    Hi
    You need to use "RANK() OVER" to get the desired output


    SELECT Student_Name, TotalMarks,
    RANK() OVER (ORDER BY TotalMarks DESC) AS TheBest
    FROM Student


    Check out the below link
    http://weblogs.sqlteam.com/jeffs/archive/2007/03/28/60146.aspx
    http://www.4guysfromrolla.com/webtech/010406-1.shtml

    Thanks -- Vijaya Kadiyala
    http://www.DotNetVJ.com
    Microsoft MVP


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.