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.

Kindoperator
Example LanguageSQL

📝 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

aLeft operand; must be comparable with b.
bRight 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

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`.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏