SQL to select n consecutive rows
Posted on 2011-05-06
I have a table with 2 columns defined as such:
CREATE TABLE TempConsec(SpaceID varchar(100),aislesequence int)
The data in the table may be something like this:
'space 1', 1
'space 2', 2
'space 4', 4
'space 5', 5
'space 6', 6
I have a stored procedure with a parameter of the number of consecutive spaces that I want selected.
So given a stored proc like findConsecutive(3) what would the SQL code be to return rows 4,5,6 ?
I need the aislesequence values to be consecutive.