What is the meaning of 'OR' here, and how do you use OR/AND between ranges?
Write a PostgreSQL query that evaluates each observation against the two ranges configured for its range set. A match is valid when the values fit the ranges in either order. Range boundaries are inclusive, and inactive range sets must be excluded.
observation_id, range_set_id, first_value, second_value, and matched_order.range_set_id, then observation_id.range_1_then_range_2 or range_2_then_range_1.| Column | Type | Description |
|---|---|---|
| range_set_idPK | INT | Identifier for a pair of numeric ranges |
| range_set_name | VARCHAR(100) | Descriptive range set name |
| range_1_min | NUMERIC(10,2) | Inclusive lower bound of the first range |
| range_1_max | NUMERIC(10,2) | Inclusive upper bound of the first range |
| range_2_min | NUMERIC(10,2) | Inclusive lower bound of the second range |
| range_2_max | NUMERIC(10,2) | Inclusive upper bound of the second range |
| is_active | BOOLEAN | Whether the range set can be used |
| Column | Type | Description |
|---|---|---|
| observation_idPK | INT | Unique observation identifier |
| range_set_id | INT | Referenced range set |
| first_value | NUMERIC(10,2) | First value to evaluate |
| second_value | NUMERIC(10,2) | Second value to evaluate |