hard to explain... i have a character field with a 'floating' decimal point and need to order it to get the next incremental decimal place but can't get the convert/cast to work after 1 place to the right of decimal. ie) 101.1, 101.2, ... 101.9, 101.10; problem is 101.10 and 101.11 order before 101.2
how to select and convert char value with decimal point to correct decimal place
Collapse
X
-
That doesn't make any sense.
101.1 is the same thing as 101.10. That's basic math.
I don't know why you think 101.1 = 101.01, where is that even coming from? What kind of math are you using? Or is there some sort of business requirement you have not specified. If you have a special requirement that breaks the laws of math, you need to tell us about it because there's no way for us to know that by 101.1 you mean 101.01. You need to lay out the rules by which you are evaluating your numbers for us to be able to help.Comment
-
it is not math. the number to the right of the decimal is a counter. 1,2,3,4... 10, 11, 12 . The entire number and counter is stored in the same character field for some stupid reason; (101.1, 101.2 ... 101.10, 101.11) I inherited this code and would never design it this way. The 'sorting' code worked fine until the counter went to 2 digits, that is why I want 101.1 to really convert to 101.01 and not 101.10Comment
-
In that case, I would use a combination if the INSTR() function to find the location of the "." and the MID() function to separate out the 2 parts of the field. Once they have been separated, you can convert each part to an integer and sort by them.Comment
Comment