how to compare rows for a specific column in the same table

  • Hello,

    I have a table contains a column with increment numbers, how can I extract all records with increment less than 2?

    example of the table

    table [t1]

    col

    1

    2

    3

    7

    8

    14

    desired result

    col

    1

    2

    3

    7

    8

     

    Thanks in advance

     

     

  • select t1.col

    from table t1

    inner join tabe t2 on t1.col = t2.col - 1

     

    _____________
    Code for TallyGenerator

  • Thanks!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply