-2

How to convert any string into digit in SQL without CASE and Decode function. eg. THREE to 3 FOUR to 4 FIVE to 5 SIX to 6 Range is not decided.. can be vary upto N.

1 Answers1

1

Well, I'm not sure whether this is what you need, but what about defining a table, say digits, like this:

digit: text | value: int
------------+-----------
one         | 1
two         | 2
three       | 3
           etc.

Then use a query, for example, like this one:

SELECT value FROM digits WHERE digit = 'FIVE'

Sure, it's pretty weird (to say the least), but nonetheless the use of CASE is avoided.

proskor
  • 1,382
  • 9
  • 21