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.
| Author |
Topic |
|
mukhan85
Starting Member
46 Posts |
Posted - 2008-11-18 : 10:41:08
|
| Hi, I am trying to order my results by month. using the "Order by" clause, but the problem is, it is ordering like 1, 10, 11, 12, 2, 3, 4... how can I get normal ordering?Thanks. |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2008-11-18 : 10:44:00
|
| It means that your month column is a text datatype and your data is sorted alphabetically. Make sure that it's a numerical column insteda either by changing your table or doing something like this: ORDER BY CAST(myMonthColumn as INT)- Lumbago |
 |
|
|
mukhan85
Starting Member
46 Posts |
Posted - 2008-11-18 : 10:49:32
|
quote: Originally posted by Lumbago It means that your month column is a text datatype and your data is sorted alphabetically. Make sure that it's a numerical column insteda either by changing your table or doing something like this: ORDER BY CAST(myMonthColumn as INT)- Lumbago
Thanks man I appreciate :) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-18 : 10:50:40
|
quote: Originally posted by mukhan85
quote: Originally posted by Lumbago It means that your month column is a text datatype and your data is sorted alphabetically. Make sure that it's a numerical column insteda either by changing your table or doing something like this: ORDER BY CAST(myMonthColumn as INT)- Lumbago
Thanks man I appreciate :)
or just useORDER BY (myMonthColumn * 1)to allow implicit conversion. |
 |
|
|
|
|
|