• This should work for you:

    [font="Courier New"]

    -- create a table to store our results

    -- create a dummy unique identifier on the table

    CREATE TABLE #Counter2

    (

       RowNumber INT IDENTITY(1,1)

       ,StartDate DATETIME

       ,[Value] FLOAT

       ,Code CHAR(1)

       ,Counter INT

    )

    --insert all existing data from original table into our results table

    INSERT INTO #Counter2(StartDate, [Value], Code)

    SELECT StartDate

       , [Value]

       , Code

    FROM #Counter

    -- create a counter variable

    -- this will be used to count our rows

    DECLARE @Counter INT

    SET @Counter = 0

    -- this is a dummy variable

    -- we need it as an anchor to keep our running total

    DECLARE @RowNumber INT

    -- now we will set the counter

    -- we need to start the counter when the value is between 10 and 15

    -- accumulate the counter until we get to 10

    -- start again when we get to the next value between 10 and 15

    UPDATE #Counter2

    SET @Counter = Counter = CASE WHEN (@Counter >= 1 AND @Counter < 10) OR ([Value] >= 10 AND [Value] <=15)

                               THEN @Counter + 1

                               ELSE 0 -- restart the counter

                               END

       ,@RowNumber = RowNumber

    FROM #Counter2

    -- take a look at our results

    SELECT *

    FROM #Counter2

    -- clean up

    DROP TABLE #Counter2

    [/font]