Lets say we have 2 tables.
Table Values
Id Group Value
--------------------
A X 15
B Y 55
Table Ranges
Group LowLimit HighLimit
--------------------------------
X 0 10
X 20 30
Y 30 40
Y 50 60
I would like to check which Values.Id has value that falls outside the LowLimit and HighLimit of the group it belongs to in Ranges (notice each group has multiple ranges).
The desired result would be
Table Result
Id
--------------
A (because the value 15 is outside the range of both (0..10) and (20..30)
while B is not part of the result because it is within the range of (50..60) even though it is outside the range of (30..40))
What would the sql would be like?
NOT EXISTS. If you are not familiar with this, refer to w3schools.com/sql/sql_exists.asp