• Since the data depends on sequentiality, which isn't a property of relational data, you'll need a non-relational solution. That means a simple cursor.

    Step through the rows, if the TN increments by more than 1, or the TNID changes to a new value, insert the new values into a temp table as the start-range value, and update the prior row of the temp table with the last value, as the end-of-range. Then select from the temp table.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon