Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[functions] Conditional Functions #918

Closed
BohuTANG opened this issue Jun 26, 2021 · 2 comments · Fixed by #1505
Closed

[functions] Conditional Functions #918

BohuTANG opened this issue Jun 26, 2021 · 2 comments · Fixed by #1505
Assignees

Comments

@BohuTANG
Copy link
Member

BohuTANG commented Jun 26, 2021

Summary

If
Controls conditional branching. Unlike most systems, ClickHouse always evaluate both expressions then and else.
Syntax:

SELECT if(cond, then, else)

Example:

Query:

SELECT if(1, 2+2, 2+6);

Result:

┌─plus(2, 2)─┐
│          4 │
└────────────┘

Query:

SELECT if(0, 2+2, 2+6);

Result:

┌─plus(2, 6)─┐
│          8 │
└────────────┘

Reference:
https://clickhouse.tech/docs/en/sql-reference/functions/conditional-functions/#if

@BohuTANG BohuTANG added this to the v0.5 milestone Jun 26, 2021
@zhaox1n
Copy link
Contributor

zhaox1n commented Jul 5, 2021

/assignme

@zhyass
Copy link
Member

zhyass commented Jul 16, 2021

/assignme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants