Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2007
    Posts
    65

    Unanswered: Identify missing sequential numbers

    Hello to everyone.

    I have a table with records sequentially numbered (incremented by 1). I need to identify eventual gaps in this numbering. I know a bit of SQL but I’m completely clueless of how to do it. Can it be done using only SQL? If yes I’ll appreciate if someone can explain me how to do it.
    RDBMS version is 9.2.0.7.0

    Thanks in advance for any help.
    Octavio

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    generate a contiguous sequence of values utilizing CONNECT BY
    MINUS
    SELECT USER_ID ....

    the result set will be the "missing" values or gaps.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jun 2007
    Posts
    65
    Anacedent, thank you.

    But sorry for being so dumb, i was unable to use your help.
    Being my table AP_INVOICES_ALL and the column containing the numbering DOC_SEQUENCE_VALUE how it will be the complete SQL syntax?
    Sorry again for giving you so much trouble.

    Octavio

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    SELECT ROWNUM FROM DUAL CONNECT BY LEVEL <= 6
    MINUS
    SELECT KEY_ID FROM YOUR_TABLE;

    If KEY_ID contained 2,3,4; then result set would be 1 & 5
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Jun 2007
    Posts
    65

    Thank you

    Anacedent, just brilliant. I'm green with envy. Thank you once again.

    Octavio

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •