Numeric Filters¶
Goal: Filter by numbers — comparison, range (
BETWEEN), and a few common pitfalls.
Operators¶
| Operator | Meaning |
|---|---|
= | Equals |
<> | Not equals |
<, > | Less than, greater than |
<=, >= | Inclusive |
BETWEEN x AND y | Inclusive range |
NOT BETWEEN x AND y | Outside range |
Examples¶
BETWEEN¶
BETWEEN is inclusive on both ends:
| Use | Range |
|---|---|
POP BETWEEN 10000 AND 50000 | 10000 ≤ POP ≤ 50000 |
POP NOT BETWEEN 10000 AND 50000 | POP < 10000 OR POP > 50000 |
No quotes for numbers¶
Numeric fields take no quotes:
Float comparison¶
For floating-point fields, exact equality is risky:
NDVI = 0.5 -- ⚠ usually fails — actual value might be 0.4999999
NDVI BETWEEN 0.49 AND 0.51 -- ✅ safer
Negative numbers¶
No special syntax — minus sign is part of the literal.
Combining¶
NULL with numerics¶
A NULL value will not match any numeric comparison:
To include NULL:
To find rows where POP isn't yet captured:
Real-world examples¶
Census tracts in a population range¶
High-income above median¶
Acres per parcel range¶
Significant elevation¶
Negative growth¶
Only large parcels (with NULL handling)¶
Calculated thresholds¶
Sometimes you don't know the exact threshold but you know the relationship to another field:
ENROLLMENT > CAPACITY -- over-capacity
PRICE < AVG_PRICE -- below average (assuming AVG_PRICE field exists)
GROWTH > BASELINE * 1.1 -- 10% above baseline
Multiple ranges¶
Common mistakes¶
Avoid
- 🚫
POP > '100000'(quoted number → string compare) - 🚫
NDVI = 0.5(float equality) - 🚫 Forgetting NULLs in
</>queries - 🚫
BETWEEN 100 AND 50(inverted range — returns nothing)
Practice¶
Numeric drills
- Cities with population between 50,000 and 200,000.
- Parcels under $100,000 or over $1 million.
- Elevations in 1000–3000 m, slope < 15.
- Tracts with negative population change.
- Buffers with
DIST_M > 0(i.e., actual buffers, not zero-width).
→ Next: Text Filters.