Showing posts with label Order by clause for column datatype as character. Show all posts
Showing posts with label Order by clause for column datatype as character. Show all posts

Thursday, 7 April 2011

Order by clause for column datatype as character


Order by clause for column datatype as character

We generally cannot order the records for a column with character data type. Please use the following trick to use the order clause:

select employee_number from employees
order by lpad(employee_number,100);

Using the lpad the zeros would be appended and then sql will treat them as numbers and the employee number would be sorted.