Comparison greater-than operator >
Last updated: 2026-11-04
Comparison greater-than operator >
The greater-than operator > reports whether the left operand is larger than the right and mirrors < exactly in semantics. Together with >= it is the workhorse for range filters and threshold checks. Like every comparison operator it returns NULL rather than false when a NULL is involved, and WHERE skips those rows.
| Kind | operator |
|---|---|
| Example Language | SQL |
📝 Syntax
a > b
Precedence: it shares a level with `<`, `=`, `<=`, `>=` and `<>`, above `IS NULL`, above `NOT`, above `AND` and above `OR`; comparison operators do not chain. Write a range as `a > 10 AND a <= 20`, never as `10 < a < 20`.
⚙️ 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 gt_result, score >= 60 AS gte_result FROM t_gt ORDER BY id
id | score | gt_result | gte_result
---+-------+-----------+-----------
1 | 90 | true | true
2 | 60 | false | true
3 | NULL | NULL | NULL
(3 rows)
SELECT id, score FROM t_gt WHERE score > 70 ORDER BY id
id | score
---+------
1 | 90
(1 row)
SELECT id, score IS NULL AS score_is_null FROM t_gt WHERE id = 3
id | score_is_null
---+--------------
3 | true
(1 row)
📌 Key Points
- NULL propagation: a NULL operand yields NULL and WHERE filters the row out.
- Join range bounds with AND — chaining `10 < a < 20` does not work.
- Keep > (strictly greater) and >= (greater or equal) apart.
💡 Related Cases
More case studies coming soon.
📚 Related Reference
❓ FAQ
QWhy does 10 < score < 90 fail?
AComparison operators do not chain, so the parser cannot group the second <. Rewrite it as `score > 10 AND score < 90`.