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 965673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:02:12+00:00 2026-05-16T02:02:12+00:00

For a table like this: username | time ————————————— animuson | 0.678 aP*animuson |

  • 0

For a table like this:

username        | time
---------------------------------------
animuson        | 0.678
aP*animuson     | 0.967
animuson        | 0.567
qykumsoy        | 0.876

I’m trying to find a way in MySQL to order these by times and then find the position where username occurs and username is only counted once. So, if I’m searching for username ‘qykumsoy’, it should return 2, because both ‘animuson’ times are faster, but only the fastest one counts, then ‘qykumsoy’ is the next fastest after that. I can get them grouped and ordered, but how do I find what position that username is at? I figured just doing this in MySQL might be faster than looping through all the results in PHP, correct me if I’m wrong.

What I’ve thought of so far:

SELECT * FROM `times` ORDER BY MIN(`time`) GROUP BY `username`

I’m not very well experienced with MySQL, only the basic stuff. Any ideas?

  • 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-16T02:02:13+00:00Added an answer on May 16, 2026 at 2:02 am

    What you’re after is a rank with relation to the data in the table – MySQL doesn’t have any ranking/analytic/windowing functionality but you have two options – this:

    SELECT x.rank
       FROM (SELECT t.username, 
                             t.time,
                             (SELECT COUNT(*)
                                  FROM TABLE y
                                 WHERE y.time <= t.time) AS rank
                     FROM TABLE t) x
     WHERE x.username = 'qykumsoy'
    

    …or using a variable:

    SELECT x.rank
       FROM (SELECT t.username, 
                             t.time,
                             @rownum := @rownum + 1 AS rank
                   FROM TABLE t
                      JOIN (SELECT @rownum := 0) r
             ORDER BY t.time DESC) x
     WHERE x.username = 'qykumsoy'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called users_preferred_zips that looks like this: username | price |
I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int
MY Table like this: id Tag platform 1 #class1,#class2 CS 2 #class1 PS 3
I've table like this VB(name char(25), amount numeric(6), ret_date date): Name Amount Ret_date ----
I have a table like this ID Name IsDeleted 1 Yogesh Null 2 Goldy
I have a table like this : +-------+------------+------+-----+---------+-------+ | Field | Type | Null
I got a table like this, and use MYSQL 5.5 id --- 2 3
I have a table like this: ID country ------------- 1 US 2 Japan 3
I have a html table like this: Invoice# Due Date Balance Select 12345 12/25/2011
I have a table like this: id | id_parent | tag_name 0 | |

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.