• roy.tollison (8/29/2016)


    this gives me something to work with thanks...

    What do you want to work on?

    You've been given the solution.

    All you need to do is to translate it into SQL.

    EzipayEmailList

    1. " a 'B' type is found" - means you know min value in t_col 2 for the rows of 'B' type.

    Must be easy to find.

    declare @LastB_ID int

    select @LastB_ID = MIN(t_col2)

    FROM TeTable

    WHERE t_Type = 'B'

    3. to search for "next" 'B' type row when the firs row is 'B' type you need to add to the query 1 an extra condition:

    WHERE t_col2 > (select MIN(t_col2) from TheTable)

    declare @LastB_ID int

    select @LastB_ID = MIN(t_col2)

    FROM TeTable

    WHERE t_Type = 'B'

    AND t_col2 > (select MIN(t_col2) from TheTable)

    2. "all the rows until" - means rows with t_co2 less than the value found in (1).

    Should not cause any difficulties too.

    declare @LastB_ID int

    select @LastB_ID = MIN(t_col2)

    FROM TeTable

    WHERE t_Type = 'B'

    AND t_col2 > (select MIN(t_col2) from TheTable)

    SELECT * FROM TheTable

    WHERE t_col2 < @LastB_ID

    -- exclude the possible 1st "billing" record

    AND NOT (t_Type = 'B')

    What do you intend to work on here?

    _____________
    Code for TallyGenerator