mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
8623cb232c
* CLICKHOUSE-4063: less manual html @ index.md * CLICKHOUSE-4063: recommend markdown="1" in README.md * CLICKHOUSE-4003: manually purge custom.css for now * CLICKHOUSE-4064: expand <details> before any print (including to pdf) * CLICKHOUSE-3927: rearrange interfaces/formats.md a bit * CLICKHOUSE-3306: add few http headers * Remove copy-paste introduced in #3392 * Hopefully better chinese fonts #3392 * get rid of tabs @ custom.css * Apply comments and patch from #3384 * Add jdbc.md to ToC and some translation, though it still looks badly incomplete * minor punctuation * Add some backlinks to official website from mirrors that just blindly take markdown sources * Do not make fonts extra light * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's//g' {} * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's/ sql/g' {} * Remove outdated stuff from roadmap.md * Not so light font on front page too * Refactor Chinese formats.md to match recent changes in other languages
1.4 KiB
1.4 KiB
Conditional functions
if(cond, then, else), cond ? operator then : else
Returns then
if cond != 0
, or else
if cond = 0
.
cond
must be of type UInt8
, and then
and else
must have the lowest common type.
then
and else
can be NULL
multiIf
Allows you to write the CASE operator more compactly in the query.
multiIf(cond_1, then_1, cond_2, then_2...else)
Parameters:
cond_N
— The condition for the function to returnthen_N
.then_N
— The result of the function when executed.else
— The result of the function if none of the conditions is met.
The function accepts 2N+1
parameters.
Returned values
The function returns one of the values then_N
or else
, depending on the conditions cond_N
.
Example
Take the table
┌─x─┬────y─┐
│ 1 │ ᴺᵁᴸᴸ │
│ 2 │ 3 │
└───┴──────┘
Run the query SELECT multiIf(isNull(y) x, y < 3, y, NULL) FROM t_null
. Result:
┌─multiIf(isNull(y), x, less(y, 3), y, NULL)─┐
│ 1 │
│ ᴺᵁᴸᴸ │
└────────────────────────────────────────────┘