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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Varchar Values to Numeric ?

Status
Not open for further replies.

pwel

Programmer
Aug 18, 1999
79
GB
Can anyone help?

I have a column of textual vales that i need to convert to numeric in order to sort them properly!

The values take the following form: 1.0, 10.0, 2.5, 100.0, 3.0 etc.

The values are required to be varchar's but I need to sort them as if the were numbers. As it stands, using an normal ORDER BY rsults in the following sort order.

1.0
10.0
100.0
2.5
3.0

But I need them to be sorted as if they were numbers i.e.

1.0
2.5
3.0
10.0
100.0

Any help would be much appreciated.

Cheers.
Paul.
 
Hopefully something like this helps

SELECT CDBL(fieldname) AS Expr1
FROM tablename ORDER by CDBL(fieldname);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top