0

So basically I have a table with two fields, 'number' and 'title', and I need a query to select the row with the highest value in 'number', for this i used

SELECT MAX('number') FROM table

Now I need to get the value of 'title' that corresponds to the highest value of 'number'.

How can this be achieved?

Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • http://stackoverflow.com/questions/tagged/greatest-n-per-group+mysql This has probably been solved before. – usr Jan 01 '14 at 21:51

2 Answers2

2

Order by the number in descending order and return only one record with limit

select title
from your_table
order by number desc
limit 1
juergen d
  • 201,996
  • 37
  • 293
  • 362
0
select title, number from table where number=(select max(number) from table);
koljaTM
  • 10,064
  • 2
  • 40
  • 42