I am facing a problem in MSSQL: -
I have a table in MSSQL, which has 10 rows & 5 columns. In this table I am maintaining a numeric range in 2 columns. First one has starting number & second column has end number. All rows have unique values in these 2 columns.
For Ex.: - In first row the value in first column is 1 & in second column is 100. In another row the value in first column is 101 & in second column is 200 & so on....
Now my problem is how can we identify that a given number is coming in which range & in which row?
For ex.: - If we say number 60. Then how can we identify in MSSQL in this table the given number is coming in which range & in which row without using CURSOR??
I need to know the function or command or query or any other utility in MSSQL by which the above-mentioned task could be achieved?
Please suggest & thanks a lot in advance....
Software/Hardware used:
ASKED:
December 5, 2008 2:53 PM
UPDATED:
December 5, 2008 5:31 PM
You could also change the WHERE clause to something like this:
where range_start <= 60
and range_end >= 60
but I would prefer to use BETWEEN.