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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Order By Caluse behaving differently

Author  Topic 

SKP
Starting Member

34 Posts

Posted - 2008-05-22 : 05:40:50
Hi Guys,

There is an int filed in my table called "WeekNo" and when I use order by WeekNo Desc, I am getting the following result.
9
8
7
7
6
5
4
3
2
18
17
16
15
15
14
13
13
12
11
10
10
1

This does not seem right, can anyone comment why i am getting this result.

Many Thanks

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-05-22 : 05:46:27
Are you sure it is defined as int? or you are not converting it to varchar or char somewhere in your query?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

sandeep.y
Starting Member

1 Post

Posted - 2008-05-22 : 05:49:40
Check your column type probably it might be varchar or NVarchar, change it to Integer.

Then your order by clause will work perfectly.

-Sandeep Y.
Go to Top of Page

SKP
Starting Member

34 Posts

Posted - 2008-05-22 : 05:50:09
Hey Harsh,

It was my mistake, it has been defined as varchar, not a good day for me today.

Thanks for the obvious spotting.
How is India in summer? Where from are you in india?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-22 : 05:52:33
I dont think its int field you're ordering by. Can you post your code used?
Go to Top of Page
   

- Advertisement -