Showing posts with label ORDER BY varchar field. Show all posts
Showing posts with label ORDER BY varchar field. Show all posts

Wednesday, August 03, 2011

Ordering on Varchar Datatype column

CAST function can be used like below:

SELECT col_name from table_name
ORDER BY CAST(col_name AS SIGNED INT);

We just make the ORDER BY clause work on a integer value.That is done by CAST(col_name AS SIGNED INT) in the statement.