Select N rows before and after the matching row

 

Select N rows before and after the matching row.

Table definition:

 

Populate table:

 

Find the matching row and its nearest records – 2 before and 2 after:

Leave a Reply

Your email address will not be published. Required fields are marked *