How to find max of mysql varchar column

Viewed 61

i have a table like this with a var char field reference_number actually i need to get the max of number in that field

 <<student>>

 |`id` | `reference_number`(varchar(25))
 --------------------------
 | 1   | L250
 | 2   | SP521
 | 3   | S120
 | 4   | SP500
 | 5   | S122

the desired result is 521 because if we are avoiding the non numeric value then it will come like this

|`id` | `reference_number`
 --------------------------
 | 1   | 250
 | 2   | 521
 | 3   | 120
 | 4   | 500
 | 5   | 122

how to get the the value 521 from the table

2 Answers
Related