user961743 user961743 - 1 month ago 9
SQL Question

How To Determine If Number is Sequential In Oracle SQL

This is a second part to a previous question I'm asking. I have a table of license numbers and am trying to determine if they are legitimate. One of the tests that I'm trying to run is if the numbers are sequential/counting pattern. What would be really helpful is if I can get a count of sequential characters, but I feel that is more difficult. For example:

123456789 TRUE 9
123455678 FALSE 5
456789012 TRUE 9
12345 TRUE 5

Thanks for your help!


It will match any string of two or more digits, that consists entirely of sequential digits.

123456789     MATCH
123455678     NOT MATCH
456789012     MATCH
12345         MATCH