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
 General SQL Server Forums
 New to SQL Server Programming
 Counting

Author  Topic 

moiseszaragoza
Starting Member

8 Posts

Posted - 2009-08-26 : 11:55:11
I have a simple sort order on a int coloum but it is counting strange.

Ej.
1,10,11,12,13,14,15,16,17,18,19,2,20, ...

I would like it if it could be
1, 2, 3, 4, 5, 6, ...


my Query
SELECT * FROM TABLE ORDER BY my_Num DESC

Just keep smiling

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-26 : 12:00:29
your my_Num isn't an INT.
try ORDER BY convert(int,my_Num) DESC


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

moiseszaragoza
Starting Member

8 Posts

Posted - 2009-08-28 : 08:58:15
Thanks, that is really helpfull

Just keep smiling
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-08-28 : 09:06:00
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/07/21/ordering-interger-values-stored-in-varchar-column.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -