Comparison less-than operator <
Last updated: 2026-11-04
Comparison less-than operator <
The less-than operator < reports whether the left operand is smaller than the right, and works for numbers, text and dates. Text comparison follows the column collation and compares character by character, so uppercase letters usually sort before lowercase ones. Like every comparison operator it follows three-valued logic: a NULL operand produces NULL, and WHERE will not return that row.
| Kind | operator |
|---|---|
| Example Language | SQL |
📝 Syntax
a < b
Precedence: comparison operators share one level (`< > = <= >= <>`), above `IS NULL`, above `NOT`, above `AND` and above `OR`. They do not chain, so compound conditions need parentheses or a logical operator: `a < b AND c < d` is fine, `a < b < c` is a syntax error.
⚙️ Parameters
| a | Left operand; must be comparable with b. |
|---|---|
| b | Right operand; must be comparable with a. |
Returns:The boolean true, false, or NULL when either operand is NULL.
▶ Example
Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.
Output:
SELECT id, score, score < 70 AS lt_result FROM t_lt ORDER BY id
id | score | lt_result
---+-------+----------
1 | 90 | false
2 | 60 | true
3 | NULL | NULL
(3 rows)
SELECT id, score FROM t_lt WHERE score < 70 ORDER BY id
id | score
---+------
2 | 60
(1 row)
SELECT id, score IS NULL AS score_is_null FROM t_lt WHERE id = 3
id | score_is_null
---+--------------
3 | true
(1 row)
📌 Key Points
- NULL propagation: a NULL operand makes the comparison NULL and WHERE filters the row out.
- For possibly-NULL columns use `IS NULL` / `IS NOT NULL` instead of `= NULL`.
- Text comparison depends on the collation, so ordering can differ between databases.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QDoes score < 70 return rows where score is NULL?
ANo. NULL < 70 evaluates to NULL and WHERE keeps only true rows, so rows with a NULL score are filtered out.