Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 Sorting numerically with a character field

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-01-18 : 10:45:07
Laura writes "I have a field that is defined as character. The field contains values of A - Z and 1 - 215. I need to sort the data so that it appears as A - Z first and then the numbers. I then need to add one (1) to the highest numeric value. The database is in DB2 and I'm getting errors when trying to use TO_NUM to convert the alpha characters."

izaltsman
A custom title

1139 Posts

Posted - 2002-01-18 : 11:46:51
Instead TO_NUM function you should be able to use CAST (or convert). You will probably need a CASE statement as well to check for any non-numeric characters before you try to CAST it as number.

Go to Top of Page
   

- Advertisement -