I have the following table:
ID Name Items
-------------------------------------
1 John 7
2 Peter 533
3 Chang 13
4 Mike 9100
I want to order it by Items. I used ORDER BY items ASC, but it returns:
ID Name Items
-------------------------------------
3 Chang 13
2 Peter 533
1 John 7
4 Mike 9100
I want to return:
ID Name Items
-------------------------------------
1 John 7
3 Chang 13
2 Peter 533
4 Mike 9100
I think this might be a silly question, but I really don't have any ideas about how to solve this.
Thanks.
Best Answer
Only explanation I can think of that result, if you are sorting with
Order By Items ASC
as you said, is thatItems
column is of character datatype (eitherVARCHAR
orCHAR
) instead of numeric.13, 533, 7, 9100
are in lexicographical order, not numerical order.Check the data type of that column.