Convert Fraction To Decimal
Working on 10g. I am writing a query to sort a list, and sorting is an important aspect of the list. I have already isolated the fraction from the mixed number. I have data that co
Solution 1:
This will blow up badly if the input is not a fraction such as 3/4, 5/8, etc., but here goes:
CAST(SUBSTR(theFraction, 1, INSTR(theFraction, '/')-1) AS NUMBER) /
CAST(SUBSTR(theFraction, INSTR(theFraction, '/')+1) AS NUMBER)
The logic is basically "get everything before the '/' and convert it to a number, then divide it by everything after the '/' converted as a number".
Post a Comment for "Convert Fraction To Decimal"