Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a column 1

Status
Not open for further replies.

mailtome

IS-IT--Management
Dec 10, 2004
5
IN
Hi
I have a varchar column say Issue with data as follow

900
1100
update
test
800

Now I want to sort this column but the sort by query sorts it like

1100
800
900
test
update

Can anyone tell me the correct way to sot this column
 
Nice idea Rudy, but what happens with a value like "r937"? It matches the regex, so goes to the start of the list. [tt]REGEXP '^[0-9]'[/tt] might be an improvement, depending on what order the OP wants.
 
SELECT col FROM foo
ORDER BY col REGEXP "^[^0-9]", col+0, col

This query works while sorting in ascending order
While SELECT col FROM foo
ORDER BY col REGEXP "^[^0-9]", col+0, col DESC doesnt works :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top