Forum Moderators: coopster
I'm reporting a list of products out of a MySQL DB and ordering them by "unitprice" which is numeric.
The list it returns mostly correct except that the order goes as such:
1.34
11.45
11.56
2.34
3.56
9.45
What is the correct "order By" method (or what am I doing wrong with the current one) to get it to order correctly.
1.34
2.34
3.56
9.45
11.45
11.56
Thanks in advance.
Russ
SELECT * FROM myTable ORDER BY CAST(unitprice AS DECIMAL(6,2)) ASC
IS there something else I need to do here?
R
UPDATE: Nevermind.. I found it... I used your other example above and figured out what I was doing wrong... As a decimal, I needed to add the length (6,2)
One question... is the first number(6) the number of places BEFORE the decimal? Or the TOTAL length of the string?