Sponsored by Travelzoo
$52 and Up—Airlines Slash Fares On Peak Holiday Flights. view!
travelzoo.com - This year, waiting until the last minute is NOT the best strategy. See why.
4 Comments
- Moskie, on 10/12/2007, -0/+3why not change the data type of the column? why are you storing a decimal value in a varchar to begin with?
- pigdart, on 10/12/2007, -0/+2SQL is doing exactally what it should. If you need a numeric sort you should use a numeric data type.
- Moskie, on 10/12/2007, -0/+0You have to realize that sorting numerically *is* a mathematical operation.
Calculating whether 2 < 10 is as much mathematical as anything else, and that's what has to be done to do this sort properly. So... it should be stored as a numeric data type. - pissedoffsol, on 10/12/2007, -0/+0Because it's not a number, it's a "Text equivilent numerical code" I guess you could call it. Storing a field that you will NEVER do math on, such as a zipcode, a phone number, or in this example, my "Codes" should be stored as a varchar as it is merely Text.
This is no different than storing codes as say A,B,C and running an ORDER BY on it. This will work though, because the text string sorting works for apha characters, but not so perfect for text string characters that 'look like numbers'. I hope that makes sense.


What is Digg?
The Digg Toolbar for Firefox lets you Digg, submit content, and keep track of Digg even when you're not on the Digg site. Download the official