You need to enable JavaScript to run this app.
ByteHouse Cloud Data Warehouse Version

ByteHouse Cloud Data Warehouse Version

Copy page
Download PDF
Function reference
Logical comparison functions
Copy page
Download PDF
Logical comparison functions

and

Calculate the logical connection result between two or more values. Corresponds to the logical AND operator.
Syntax

and(val1, val2...)

Param

  • val1, val2, ...— A list of at least two values. Int, UInt, Float, or Nullable.

Return value

  • 0, if at least one parameter is zero.
  • NULL, if there are no zero-value parameters and at least one NULL parameter.
  • 1, in other cases.

Type: UInt8 or Nullable(UInt8).
Example

SELECT and(0, 1, -2);
┌─and(0, 1, -2)─┐ 
│ 0             │ 
└───────────────┘

and NULL:

SELECT and(NULL, 1, 10, -2);
┌─and(NULL, 1, 10, -2)─┐ 
│ ᴺᵁᴸᴸ                 │ 
└──────────────────────┘

or

Calculate the logical OR result between two or more values. Corresponds to the logical OR operator.
Syntax

or(val1, val2...)

Param

  • val1, val2, ...— A list of at least two values. Int, UInt, Float, or Nullable.

Return value

  • 1, if at least one value is not zero.
  • 0, if all values are zero.
  • NULL, if all values are zero and NULL.

Type: UInt8 or Nullable(UInt8).
Example

SELECT or(1, 0, 0, 2, NULL);
┌─or(1, 0, 0, 2, NULL)─┐ 
│ 1                    │ 
└──────────────────────┘

xor

Calculate the logical exclusive OR result between two or more values. For more than two values, this function works by first calculating XOR for the first two values, then using the result and the next value to carry on XOR, and so on.
Syntax

xor(val1, val2...)

Param

  • val1, val2, ...— A list of at least two values. Int, UInt, Float, or Nullable.

Return value

  • 1, for two values: if one value is zero and the other is not zero.
  • 0, for two values: if both values are zero or both are not zero.
  • NULL, if at least one NULL value.

Type: UInt8 or Nullable(UInt8).
Example

SELECT xor(0, 1, 1);
┌─xor(0, 1, 1)─┐ 
│ 0            │ 
└──────────────┘

and NULL:

SELECT xor(NULL, 0);
┌─xor(NULL, 0)─┐ 
│ ᴺᵁᴸᴸ         │ 
└──────────────┘
Last updated: 2026.03.31 16:14:29