I'm using a SQL-statement to retrieve the top 5 entries in a list:
SELECT ... FROM table ORDER BY someColumn DESC LIMIT 5
The result will look something like this:
Name Count
Person B 10
Person D 8
Person A 5
Person E 5
Person C 4
If there are more results with a value like the fifth entry in the list (4 in the example), I would like to show them too. Is there a way to achieve this with a single query?
So let's say the complete lists looks like this:
Name Count
Person B 10
Person D 8
Person A 5
Person E 5
Person C 4
Person H 4
Person I 4
------------
Person G 3
Person F 1
Person J 1
How can I modify my query to return the first seven results? Obviosuly I can't use LIMIT 7 or WHERE Count >= 4, as I don't know that in advance.
10, 10, 10, 10, 10, 10, 10, 5, 4, 3, 2, 1? Will you show the 7 rows with count = 10? Or 7 rows with count = 10 + 4 rows with count between 5 and 2?10s. Notice the two5, 5in the question.