Finding if a value falls between several numbers ranges

Matt020

New member
Local time
Today, 23:47
Joined
Apr 28, 2011
Messages
6
Hi. I am using a query to determine if a number falls with the range of multiple pairs of values. The start and end value of each range is pre entered on a single table on adjacent columns, i.e first number range, start value column A, end value column B; second number range, start value column C and end value column D etc etc. The problem is that there can be up to 60 pairs of values (the ranges can overlap!), so there a way of writing a query expression that doesn't nessecitate me writing IIF, BETWEEN and OR for every single pair of values (the expression becomes huge!). i.e is there a way of automatically progressing to subsequent columns to check each pair of values on some kind of loop function? Apologies in advance if I've made complete nonsense out of this. Thanks
 
This would be simple if your number ranges were always in columns A and B, and you had a row for each pair. Then you could write an SQL WHERE clause that tests for ...
Code:
WHERE A < X AND X < B
 
Thanks, I'll try that. Originally, I wanted to be able to put a desciption of what the specific set of number ranges relate to, followed by the applicable ranges on the subsequent columns so everything I need ends up on the same record within one table (there will be thousands of these individual records). I'll see if I can tie in the identifying description in some other fashion.
 

Users who are viewing this thread

Back
Top Bottom