Skip to main content

IF

如果 <cond1> 为 TRUE,则返回 <expr1>。否则,如果 <cond2> 为 TRUE,则返回 <expr2>,依此类推。

语法

IF(<cond1>, <expr1>, [<cond2>, <expr2> ...], <expr_else>)

示例

SELECT IF(1 > 2, 3, 4 < 5, 6, 7);

┌───────────────────────────────┐
if((1 > 2), 3, (4 < 5), 6, 7)
├───────────────────────────────┤
6
└───────────────────────────────┘
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today