Ragnar Lothbrok Ragnar Lothbrok - 1 month ago 5
MySQL Question

Find all highest values of a column in an SQL table

I would like to select all the rows with the highest number, which is 293 in this case. However, it could be any number as I don't know it up front. So a simple where clause won't be sufficient. I already tried something with MAX() but that only took 1 row while I need all of them. Can anyone help me?

ID NUMBER
1 293
2 293
3 293
4 148
5 96

Answer

This is very basic:

SELECT *
FROM YourTable
WHERE NUMBER = (SELECT MAX(NUMBER) FROM YourTable);
Comments