How would I find all records in a number column (Oracle) which have 3 digits in Sequence. Would I have to use substr to break down the number to individual digits and then subtract first and second digit to see if they are 1 or -1? Is there a better way to do it? Could I break down the number into digits and pass them to a varray in a pl/sql block? Please help.
Advertisement
Answer
Assuming that you mean “sequential” as in 1-2-3, then you can use brute force:
(case when regexp_like(ssn, '012|123|234|345|456|567|678|789') then 'in sequence' else 'not in sequence' end)