Why Soundex function does not work for numbers?

We have gone through how amazing Soundex function really is. When used with letters it returns strings that are phonetically equivalent to each other and sounds alike in English. Also, we gained knowledge about the wonderful algorithm that works behind its back. Believe me, if you are a technical developer having an understanding of this function sometimes proves to be extremely useful. But due to some reason Soundex function does not retrieve any output if used with numbers.

Read here to learn how algorithm of Soundex function works

What is the problem of Soundex with numbers then?

Before we figure out reason for why Soundex does not work with numbers let us go through its algorithm first

  1. Retain the first letter of the string
  2. Remove all other occurrences of the following letters: a, e, h, i, o, u, w, y (or change it to zero ‘0’)
  3. Assign digits to the remaining letters (after the first) as follows:
    b, f, p, v = 1
    c, g, j, k, q, s, x, z = 2
    d, t = 3
    l = 4
    m, n = 5
    r = 6
  4. If two or more letters with the same number were adjacent in the original name (before step 1), or adjacent except for any intervening h and w, then omit all but the first.
  5. Replace the first digit with the letter (as in Step 1)
  6. If the string is less than 4 letters pad ‘0’ on the right. If it is more than 4 letters return only the first four positions.

The Reason

If you look closely at Step 2 we can see that a numeric digit is assigned to a letter or set of letters except for those mentioned in Step 1. But for numbers, there is no such assignment of numeric digits.

So if we use numbers as characters in Soundex function there will be nothing assigned to them and query will not retrieve any rows.

For example, below query will give no output:

Did you like the above post? Leave the comments below. Your suggestions and feedback are always welcome.

Subscribe here to stay updated on latest posts of your favorite website OracleMine.com.

Hi I am Paras.

Thanks for stopping by at OracleMine.com. Speaking about my brief introduction, I work for a multinational organisation in Oracle related technologies. Being an avid blogger, I would like to inform you about my productivity and motivational blog XpressPlanet.com. Speaking of OracleMine.com, I will try my best to share knowledge on technologies in as simple and understandable manner as possible. You can also contribute your knowledge on OracleMine by writing to us at hioraclemine@gmail.com. Again I appreciate your visit. Hope to see you again and again!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.