Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i get this list from database using oracle query..

but i want to list only missing sequence numbers .

can i do this?

ORDERNUMBER
B012020000000001
B012020000000002
B012020000000003
B012020000000005
B012020000000006
B012020000000007
B012020000000008
B012020000000009
B012020000000011
B012020000000012
B012020000000013
B012020000000015
B012020000000016
B012020000000017
B012020000000018
B012020000000019



B012020000000004
B012020000000010 
B012020000000014 


What I have tried:

"SELECT DISTINCT(ORDERNUMBER) FROM TABLE1 ORDER BY ORDER BY ORDERNUMBER"
Posted
Updated 10-Sep-20 1:02am

1 solution

The first thing to try is Google: oracle list only missing sequence numbers - Google Search[^]
Follow a few links there, and you'll find a number of ways.
 
Share this answer
 
Comments
Member 14588284 10-Sep-20 10:31am    
Yes i write GOOGLE for this question but i didn't find any question like my question ,
generally for series number like 1-2-3-4-5-6
OriginalGriff 10-Sep-20 10:35am    
It's the same thing: just you need to look at how you generate and use your sequence.
Have a look at the other solutions, and learn how they work. Then apply that to your specific database.
Member 14588284 10-Sep-20 10:41am    
But i tried :(

query = "SELECT min_sno - 1 + level missing_number FROM (SELECT MIN(ORDERNUMBER) min_sno, MAX(ORDERNUMBER) max_sno TABLE1 ) CONNECT BY level <= max_sno - min_sno + 1 minus SELECT ORDERNUMBER FROM TABLE1 "

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900