• # How 101 less than 2 ?

why 101 less than 2 in varchar field.(101 come first in ascending order before 2)please explain.........................
• if the data base field is varchar then it arrange with 1,2,3 like that, so the all the values start from 1 will soft first and then it takes the values start from 2 and finally all alphabets
so to resolve your error you need to use CONVERT method (which is inbuilt in sql)
see below snippet
`SELECT * FROM table1 ORDER BY convert('column1', decimal) ;`
hope it helps

Thanks
Koolprasd2003
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]

• Hi

can you explain more. I canot get your words what you saying.

Name : Dotnet Developer-2015
Email Id : kumaraspcode2009@gmail.com

'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

• i want to know the reason of this sequence
1
101
10101
1010101
1010102
1010103
1010104
10102
1010201
1010202
1010203
1010204
102
2
201

• There are many ways to sorting. Numerical, String, etc..
If you sort the numeric data it will come as follows
1
2
101
102
201
10101
10102
1010101
1010102
1010103
1010104
....
If you sort the string data data it will come as follows
1
101
10101
1010101
1010102
1010103
1010104
10102
1010201
....
For the string data type it will sort based on the numeric value. It will take as string value.
All are based on you data type. Which data type you are using?. I hope you are using string data type.

By Nathan
Direction is important than speed

• Hi,

Varchar field is nothing but a string format, so you are sorting result in string format, in string format the result should be 1, 101,10101.... then 2, 202,20202 etc... 3,303,.....

--------------------------------------------------------------------------------