Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 679835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:18:14+00:00 2026-05-14T01:18:14+00:00

Earlier I asked this question , which basically asked how to list 10 winners

  • 0

Earlier I asked this question, which basically asked how to list 10 winners in a table with many winners, according to their points.

This was answered.

Now I’m looking to search for a given winner X in the table, and find out what position he is in, when the table is ordered by points.

For example, if this is the table:

     Winners:
NAME:____|__POINTS:
Winner1  |  1241
Winner2  |  1199
Sally    |  1000
Winner4  |  900
Winner5  |  889
Winner6  |  700
Winner7  |  667
Jacob    |  623
Winner9  |  622
Winner10 |  605
Winner11 |  600
Winner12 |  586
Thomas   |  455
Pamela   |  434
Winner15 |  411
Winner16 |  410

These are possible inputs and outputs for what I want to do:

Query:  "Sally", "Winner12", "Pamela", "Jacob"
Output: 3        12          14        623

How can I do this? Is it possible, using only a MySQL statement? Or do I need PHP as well?

This is the kind of thing I want:

WHEREIS FROM Winners WHERE Name='Sally' LIMIT 1

Ideas?

Edit – NOTE: You do not have to deal with the situation where two Winners have the same Points (assume for simplicity’s sake that this does not happen).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:18:15+00:00Added an answer on May 14, 2026 at 1:18 am

    I think this will get you the desired result. Note that i properly handles cases where the targeted winner is tied for points with another winner. (Both get the same postion).

    SELECT COUNT(*) + 1 AS Position
    FROM myTable
    WHERE Points > (SELECT Points FROM myTable WHERE Winner = 'Sally')
    

    Edit:
    I’d like to “plug” Ignacio Vazquez-Abrams‘ answer which, in several ways, is better than the above.
    For example, it allows listing all (or several) winners and their current position.
    Another advantage is that it allows expressing a more complicated condition to indicate that a given player is ahead of another (see below). Reading incrediman‘s comment to the effect that there will not be “ties” prompted me to look into this; the query can be slightly modified as follow to handle the situation when players have same number of points (such players would formerly have been given the same Position value, now the position value is further tied to their relative Start values).

    SELECT w1.name, (
      SELECT COUNT(*)
      FROM winners AS w2
      WHERE (w2.points > w1.points) 
         OR (W2.points = W1.points AND W2.Start < W1.Start)  -- Extra cond. to avoid ties.
    )+1 AS rank
    FROM winners AS w1
    -- WHERE W1.name = 'Sally'   -- optional where clause
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.