比较函数

请注意:
下文中的一些示例引用自 ClickHouse 社区文档 并经过一定修改确保可以在 ByteHouse 中正常使用。

greatest

Returns the largest value of a and b.

Syntax

greatest(a, b)

Arguments

  • a,b – two values to compare

Returned value

  • the larger value of a,b.

Example

SELECT greatest(1, 2)
┌─greatest(1, 2)─┐
│ 2              │
└────────────────┘
SELECT greatest(toDate('2019-01-01'), toDate('2019-01-02'))
┌─greatest(toDate('2019-01-01'), toDate('2019-01-02'))─┐
│ 2019-01-02                                           │
└──────────────────────────────────────────────────────┘

notEquals

notEquals, a != b and a <> b operator

Syntax

notEquals(a, b)
a!=b
a<>b

Arguments

  • a,b – two values to compare

Returned value

  • UInt8

Example

SELECT notEquals(1, 1), 1!=1, 1<>1
┌─notEquals(1, 1)─┬─notEquals(1, 1)─┬─notEquals(1, 1)─┐
│ 0               │ 0               │ 0               │
└─────────────────┴─────────────────┴─────────────────┘
SELECT notEquals(1, 2), 1!=2, 1<>2
┌─notEquals(1, 2)─┬─notEquals(1, 2)─┬─notEquals(1, 2)─┐
│ 1               │ 1               │ 1               │
└─────────────────┴─────────────────┴─────────────────┘

notEquals

notEquals, a != b and a <> b operator

Syntax

notEquals(a, b)
a!=b
a<>b

Arguments

  • a,b – two values to compare

Returned value

  • UInt8

Example

SELECT notEquals(1, 1), 1!=1, 1<>1
┌─notEquals(1, 1)─┬─notEquals(1, 1)─┬─notEquals(1, 1)─┐
│ 0               │ 0               │ 0               │
└─────────────────┴─────────────────┴─────────────────┘
SELECT notEquals(1, 2), 1!=2, 1<>2
┌─notEquals(1, 2)─┬─notEquals(1, 2)─┬─notEquals(1, 2)─┐
│ 1               │ 1               │ 1               │
└─────────────────┴─────────────────┴─────────────────┘