views:

18

answers:

2

Hello,

I need to use the MySQL Order By function in a query except I need it to be in reverse order by number - therefore like 45, 32, 12, 10 instead of 10, 12, 32, 45. I would then limit it to 1 so I would get the highest number in the list. However if you have another way to do this that would be great thanks :D

Anyway thanks for your help!

Christian Stewart

A: 

you want: ORDER BY numeric_column DESC

the DESC reverses it. (You can then add LIMIT after that)

Cfreak
+1  A: 

Two options - using LIMIT:

  SELECT yt.numeric_column
    FROM YOUR_TABLE yt
ORDER BY yt.numeric_column DESC
   LIMIT 1

Using MAX:

SELECT MAX(yt.numeric_column)
  FROM YOUR_TABLE yt
OMG Ponies
Thanks, max worked.
Christian Stewart