2020-04-03 13:23:32 +00:00
|
|
|
|
---
|
|
|
|
|
toc_priority: 36
|
|
|
|
|
toc_title: Comparison
|
|
|
|
|
---
|
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
|
# Comparison Functions {#comparison-functions}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
|
|
|
|
Comparison functions always return 0 or 1 (Uint8).
|
|
|
|
|
|
|
|
|
|
The following types can be compared:
|
|
|
|
|
|
2020-03-21 04:11:51 +00:00
|
|
|
|
- numbers
|
|
|
|
|
- strings and fixed strings
|
|
|
|
|
- dates
|
|
|
|
|
- dates with times
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
|
|
|
|
within each group, but not between different groups.
|
|
|
|
|
|
2020-03-20 10:10:48 +00:00
|
|
|
|
For example, you can’t compare a date with a string. You have to use a function to convert the string to a date, or vice versa.
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
|
|
|
|
Strings are compared by bytes. A shorter string is smaller than all strings that start with it and that contain at least one more character.
|
|
|
|
|
|
2020-03-18 18:43:51 +00:00
|
|
|
|
## equals, a = b and a == b operator {#function-equals}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-06-08 05:29:08 +00:00
|
|
|
|
## notEquals, a != b and a \<\> b operator {#function-notequals}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
|
## less, \< operator {#function-less}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
|
## greater, \> operator {#function-greater}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
|
## lessOrEquals, \<= operator {#function-lessorequals}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-04-30 18:19:18 +00:00
|
|
|
|
## greaterOrEquals, \>= operator {#function-greaterorequals}
|
2017-12-28 15:13:23 +00:00
|
|
|
|
|
2020-01-30 10:34:55 +00:00
|
|
|
|
[Original article](https://clickhouse.tech/docs/en/query_language/functions/comparison_functions/) <!--hide-->
|