← case operator page · conditional/case/sc/true_condition_gives_then_operand
pandas ✅ · DuckDB ✅
case when SC_1 > SC_2 then 2 else 5 with SC_1 = 3 and SC_2 = 0: one when, with a true condition.
Case: "The case operator returns the first thenOperand whose corresponding condition evaluates to true, elseOperand if none of the when conditions evaluates to true."
SC_r = 2, an Integer: SC_1 > SC_2, that is 3 > 0, is true, so the result is its thenOperand.
SC_r := case when SC_1 > SC_2 then 2 else 5;
| SC_1 | SC_2 |
|---|---|
| 3 | 0 |
{
"scalars": [
{"name": "SC_1", "type": "Integer"},
{"name": "SC_2", "type": "Integer"}
]
}
{
"scalars": [
{"name": "SC_r", "type": "Integer", "value": "2"}
]
}