2017-12-28 15:13:23 +00:00
# Comparison functions
Comparison functions always return 0 or 1 (Uint8).
The following types can be compared:
- numbers
- strings and fixed strings
- dates
- dates with times
within each group, but not between different groups.
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.
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.
2018-03-25 02:04:22 +00:00
Note. Up until version 1.1.54134, signed and unsigned numbers were compared the same way as in C++. In other words, you could get an incorrect result in cases like SELECT 9223372036854775807 > -1. This behavior changed in version 1.1.54134 and is now mathematically correct.
2017-12-28 15:13:23 +00:00
2019-09-06 09:07:23 +00:00
## equals, a = b and a == b operator {#function-equals}
2017-12-28 15:13:23 +00:00
2019-09-06 09:07:23 +00:00
## notEquals, a ! operator= b and a `<>` b {#function-notequals}
2017-12-28 15:13:23 +00:00
2019-09-06 09:07:23 +00:00
## less, `< operator` {#function-less}
2017-12-28 15:13:23 +00:00
2019-09-06 09:07:23 +00:00
## greater, `> operator` {#function-greater}
2017-12-28 15:13:23 +00:00
2019-09-06 09:07:23 +00:00
## lessOrEquals, `<= operator` {#function-lessorequals}
2017-12-28 15:13:23 +00:00
2019-09-06 09:07:23 +00:00
## greaterOrEquals, `>= operator` {#function-greaterorequals}
2017-12-28 15:13:23 +00:00
2018-10-16 10:47:17 +00:00
[Original article ](https://clickhouse.yandex/docs/en/query_language/functions/comparison_functions/ ) <!--hide-->