Questions tagged [rank]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
30
votes
8answers
122k views

Get the rank of a user in a score table

I have a very simple MySQL table where I save highscores. It looks like that: Id Name Score So far so good. The question is: How do I get what's a users rank? For example, I have a users ...
2
votes
1answer
5k views

Solving “Gaps and Islands” with row_number() and dense_rank()?

How does one solve the islands part of gaps-and-islands with dense_rank() and row_number(). I've seen this now a few times and I'm wondering if someone could explain it, Let's use something like this ...
2
votes
1answer
1k views

Percentile rank that takes sorted argument (or same functionality) in PostgreSQL 9.3.5

How do I calculate the percentile of the nth element in a field relative to the ones previous to it in a time series for each subset (partition) of my data? For example, this is exactly what I want ...
2
votes
1answer
323 views

Display equal ranking if count is the same

I am trying to figure out how to display ranking correctly where if multiple authors have the same article count then they get the same ranking and then the ranking resume at the correct spot. For ...
7
votes
1answer
5k views

How to optimise window queries in postgres

I have the following table with approximately 175k records: Column | Type | Modifiers ----------------+-----------------------------+-----------------------...
3
votes
3answers
832 views

Sum of points and rank according to points

I am creating a game where I am calculating the user points on the basis of user activities. Everything is working fine - I got the sum of points and on the basis of points I calculated the rank. I ...
1
vote
2answers
7k views

How to get latest 2 records of each group

So, I have table similar to: sn color value 1 red 4 2 red 8 3 green 5 4 red 2 5 green 4 6 green 3 Now I need the latest 2 rows for each color, eg: 2 red 8 4 red 2 5 green 4 6 ...
0
votes
1answer
2k views

How to find Rank of row in MySQL

I am new to MySQL. I know that ROW_NUMBER() OVER (PARTITION) will not work in MySQL. I want to convert the code from SQL Server to MySQL: SELECT *, ROW_NUMBER() OVER ( Partition By X....