SQL - determine if a given number does not lie within any range of numbers within a set of ranges
Posted on 2008-06-18
Is there an easy way to determine if a given integer is not within a set of ranges of integers? I have a table - tblRange with columns intStart and intEnd. Each record in tblRange consists of records similar to this: intStart = 5, intEnd = 10; intStart = 1, intEnd = 6; intStart = 11, intEnd = 20, etc. For each record, intStart is always >= intEnd and intStart >= 0. Given n, how can determine if n does not lie within (inclusive) any of tblRange's records ranges?