select all values that contain a specific value (Oracle)

Good morning folks- I have a table that has a 13 digit field, the last two numbers are a sequence number, I need to find all records that have a 99 code (which is an error in this application) and list the record# and all previous sequences in that number...

An example of the number could be

in this example the record# 1111111111111 has 4 different "Sequences"

I need to find all the ones that have a 99 sequence and I want to see what other sequences are under that same number (in my above example I would want to select the 21111111111111 record because it has a 99 sequence and I want to list out all the other sequences for that record(01,02)

In a perfect world I would have the record number and then the sequence separated
2111111111111 - 01
2111111111111 - 02

Doing a mix using something simple like a substr I am only getting the 99 sequence, not all the others....

I know there is some very simple answer I'm just overlooking it and trying to over complicate it...

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Off the top of my head this is what I came up with first.
drop table tab1 purge;
create table tab1(col1 varchar2(15));
insert into tab1 values('111111111111101');
insert into tab1 values('111111111111102');
insert into tab1 values('111111111111103');
insert into tab1 values('111111111111104');
insert into tab1 values('111111111111201');
insert into tab1 values('111111111111202');
insert into tab1 values('211111111111101');
insert into tab1 values('211111111111102');
insert into tab1 values('211111111111199');

select t1.first || ' - ' || t1.last
from (select substr(col1,1,13) first, substr(col1,14,2) last from tab1) t1
where first in (select substr(col1,1,13)  from tab1 where col1 like '%99')

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hej613Author Commented:
Thanks! :)
try these, in particular I recommend the first one
oh, sorry I was too slow to respond.

however, I still recommend the first query in my file.  

slightwv's query should work, but it suffers from the same problem as my second query
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.