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!

Query - Sort Alpha as Numeric 1

Status
Not open for further replies.

RoguePoet01

Programmer
Oct 1, 2003
302
US
Hi,

I have a table with Silo numbers listed in them, but they're listed as alpha, not numeric.

So when I do a sort, I get:

1
10
11
2
3
4
...

Instead of:

1
2
3
4
...
10
11

Is there any way around this?

Thanks.
 
One thing I did to ensure these are in "numeric" order is cast the values as ints when ordering:

select field1 from table order by cast(field1 as int)

There may be a more elegant way out there though.

Tim
 
That's a big help. I found something similar.

Select * from Table Order by CONVERT(Int, Silo)

Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top