I have 2 columns, say dialer_code and country_code. I need to check whether the dialer_code matches with the country_code or not.
Example: dialer_code = 1234567890, so it will check whether 1234567890 in country_code matches any country_code entry. If not then it will remove the last digit (turning the value into 123456789) and check again. This repeats until only the first 2 digit are left.
dialer_code    country_code     country_name
190095               91         India
190098               44         UK
4456                 20         Egypt
445678               1900       US
In the above example, 190095 will be checked in country_code, but we don't have anything matching with it so now it will check for country_code 19009, but we don't have anything matching it either, until we get to 1900. Now it's matching with US. So US has some call rate defined per second so it will return that value.