Performing calculation using two rows from the same table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mamin
    New Member
    • Apr 2007
    • 5

    Performing calculation using two rows from the same table

    I have a table that contains file name, file seq num, etc. I would like to compare the two rows to make sure the file seq num is being incremented by one or more. If it is incremented >1 then I l know that there is a file missing.
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try this:

    [PHP]select sequence
    from table a
    where not exists(select sequence from table where sequence = a.sequence + 1)[/PHP]

    Good Luck.

    Comment

    • mamin
      New Member
      • Apr 2007
      • 5

      #3
      Originally posted by iburyak
      Try this:

      [PHP]select sequence
      from table a
      where not exists(select sequence from table where sequence = a.sequence + 1)[/PHP]

      Good Luck.

      Thank you. I will try that.

      Comment

      Working...