Forum Moderators: coopster

Message Too Old, No Replies

Getting order from select statements right

         

amikin

12:32 am on Mar 8, 2007 (gmt 0)

10+ Year Member



I'm pulling a bunch of times in 24 hour format from a db so values range between 6:00 and 20:00

problem is when i do the order by asc it counts 10:00 before 8:00

I also have the values translated to decimal values, so 10:45 would be 10.75, but the ordering will still put 2 digit values before the single digit, ie 10.75 will come before 9.75

is there any way to force it to go in actual numeric order

eelixduppy

3:36 am on Mar 8, 2007 (gmt 0)



>> decimal values

To select the results in ascending or descending order you must have the correct column type. The way it looks now you have it as a string type. For it to work correctly, you want the column to be of type FLOAT.

Numeric Types [dev.mysql.com]

amikin

4:32 pm on Mar 8, 2007 (gmt 0)

10+ Year Member



that was my suspicion.

can i change the column from varchar to float now that the table is set up and has data in it already, or will that cause problems?

amikin

6:16 pm on Mar 8, 2007 (gmt 0)

10+ Year Member



got it all sorted out and working fine

thanks for the help, that was a much quicker fix than what my other option was