ClickHouse/doc/reference/en/functions/comparison_functions.rst

37 lines
1.1 KiB
ReStructuredText
Raw Normal View History

2017-04-26 19:16:38 +00:00
Comparison functions
2017-04-03 19:49:50 +00:00
------------------
2017-04-26 19:16:38 +00:00
Comparison functions always return 0 or 1 (Uint8).
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +00:00
The following types can be compared:
* numbers
* strings and fixed strings
* dates
* dates with times
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +00:00
within each group, but not between different groups.
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +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-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +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.
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +00:00
Note: before version 1.1.54134 signed and unsigned numbers were compared the same way as in C++. That is, you could got an incorrect result in such cases: SELECT 9223372036854775807 > -1. From version 1.1.54134, the behavior has changed and numbers are compared mathematically correct.
2017-04-03 19:49:50 +00:00
2017-04-26 19:16:38 +00:00
equals, a = b and a == b operator
2017-04-03 19:49:50 +00:00
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-04-26 19:16:38 +00:00
notEquals, a != b and a <> b operator
2017-04-03 19:49:50 +00:00
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-04-26 19:16:38 +00:00
less, < operator
2017-04-03 19:49:50 +00:00
~~~~~~~~~~~~~~~~~
2017-04-26 19:16:38 +00:00
greater, > operator
2017-04-03 19:49:50 +00:00
~~~~~~~~~~~~~~~~~~~
2017-04-26 19:16:38 +00:00
lessOrEquals, <= operator
2017-04-03 19:49:50 +00:00
~~~~~~~~~~~~~~~~~~~~~~~~
2017-04-26 19:16:38 +00:00
greaterOrEquals, >= operator
2017-04-03 19:49:50 +00:00
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~