Alex Rivera | Logout

Return all rows with the "MAX" value in SQL?

Asked 2012-08-28T21:31:14.763
21

I have the following table:

Table: Scores What I have:

+----+-------+
| Id | value |
+----+-------+
|  1 |   300 |
|  2 |   300 |
|  3 |   300 |
|  4 |   100 |
|  5 |   200 |
+----+-------+

What I need:

+----+-------+
| Id | value |
+----+-------+
|  1 |   300 |
|  2 |   300 |
|  3 |   300 |
--------------

How would I grab "all" the top scores id 1, 2, 3 in SQL. I started off using MAX (in mysql) but that only returns one row.

Edit
Report

1 Answer

56
SELECT Id, value
    FROM Scores
    WHERE value = (SELECT MAX(value) FROM Scores);
answered 2012-08-28T21:33:50.160

Your Answer