ClickHouse/docs/zh/sql-reference/functions/conditional-functions.md
Ivan Blinkov cd14f9ebcb
SQL reference refactoring (#10857)
* split up select.md

* array-join.md basic refactoring

* distinct.md basic refactoring

* format.md basic refactoring

* from.md basic refactoring

* group-by.md basic refactoring

* having.md basic refactoring

* additional index.md refactoring

* into-outfile.md basic refactoring

* join.md basic refactoring

* limit.md basic refactoring

* limit-by.md basic refactoring

* order-by.md basic refactoring

* prewhere.md basic refactoring

* adjust operators/index.md links

* adjust sample.md links

* adjust more links

* adjust operatots links

* fix some links

* adjust aggregate function article titles

* basic refactor of remaining select clauses

* absolute paths in make_links.sh

* run make_links.sh

* remove old select.md locations

* translate docs/es

* translate docs/fr

* translate docs/fa

* remove old operators.md location

* change operators.md links

* adjust links in docs/es

* adjust links in docs/es

* minor texts adjustments

* wip

* update machine translations to use new links

* fix changelog

* es build fixes

* get rid of some select.md links

* temporary adjust ru links

* temporary adjust more ru links

* improve curly brace handling

* adjust ru as well

* fa build fix

* ru link fixes

* zh link fixes

* temporary disable part of anchor checks
2020-05-15 07:34:54 +03:00

1.5 KiB
Raw Blame History

条件函数

如果cond那么否则cond 运算符然后else

如果cond = 0则返回then,如果cond = 0则返回elsecond必须是UInt8类型,thenelse必须存在最低的共同类型。

thenelse可以是NULL

允许您在查询中更紧凑地编写CASE运算符。

multiIf(cond_1, then_1, cond_2, then_2...else)

参数:

  • cond_N — 函数返回then_N的条件。
  • then_N — 执行时函数的结果。
  • else — 如果没有满足任何条件,则为函数的结果。

该函数接受2N + 1参数。

返回值

该函数返回值«then_N»或«else»之一具体取决于条件cond_N

示例

存在如下一张表

┌─x─┬────y─┐
│ 1 │ ᴺᵁᴸᴸ │
│ 2 │    3 │
└───┴──────┘

执行查询 SELECT multiIf(isNull(y) x, y < 3, y, NULL) FROM t_null。结果:

┌─multiIf(isNull(y), x, less(y, 3), y, NULL)─┐
│                                          1 │
│                                       ᴺᵁᴸᴸ │
└────────────────────────────────────────────┘

来源文章