Results 1 to 2 of 2

Thread: SQL Query for detecting break in sequence

  1. #1
    Join Date
    Nov 2006
    Posts
    1

    SQL Query for detecting break in sequence

    I have a column,which does not have any constraint on it.It has a set of sequential values,say for eg1,2,3,4,5.....Now somewhere
    in this column the sequence breaks,i.e. say 9 comes after 7 instead of 8.My question is how do I identify such rows where there is a break in sequence?SELECT DISTINCT ....ORDER BY is not possible as the record count is extremely large.Please Help.

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    Look into documentation for LEAD clause, this allows you to compare value in next row for a column. You can check difference in values between two rows, if it is more than 1 you have a break.

Posting Permissions

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