Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2014

    Question Unanswered: Select row position from ordered query

    Hey all! Quite new here, so not sure what to expect

    I'm in need of getting the position of a row from an ordered query. I have a leaderboard, I can output each user and their position (starting with highest reputation), although I'm not sure how to get their position for their profile.

    I currently have
    PHP Code:
    $re $db->query("
                                    SELECT p.*, (SELECT count(*)+1 
    FROM uprofile WHERE prank > p.prank) AS POSITION 
    FROM uprofile p WHERE uid = 
    ORDER BY prank DESC"
    Which returns their position, although it's not unique. Take Kondax, John and Kevin for example.

    Kondax has a rank of 10, his uid is 2. John has a rank of 8, his uid is 1, same with Kevin although his uid is 3.

    The output should be as follows
    Kondax -> 10 (#1)
    John -> 8 (#2)
    Kevin -> 8 (#3)

    What's happening is, the output is coming out as follows:

    Kondax -> 10 (#1)
    John -> 8 (#2)
    Kevin -> 8 (#2)

    This is because John and Kevin have the same reputation/rank.

    Any help's appreciated

  2. #2
    Join Date
    Feb 2008
    Why not as follows?
    Kondax -> 10 (#1)
    Kevin -> 8 (#2)
    John -> 8 (#3)

  3. #3
    Join Date
    Jan 2007
    Provided Answers: 12
    If they have the same points, aren't they technically in the same position anyway?

    "Joint second"
    Home | Blog

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts