← case operator page · conditional/case/sc_multi_when/both_conditions_true
pandas ✅ · DuckDB ✅
case when SC_1 > 10 then 10 when SC_1 > 1 then 1 else 0 with SC_1 = 15: two conditions that are both true, the usual descending-threshold form, to tell the first true when from the last. In the other examples of this form at most one condition is true.
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 = 10, an Integer: SC_1 > 10 and SC_1 > 1 are both true for 15, and the first gives 10, not the 1 of the second. No recorded team decision applies, so the expected output follows the manual's "first".
SC_r := case when SC_1 > 10 then 10 when SC_1 > 1 then 1 else 0;
| SC_1 |
|---|
| 15 |
{
"scalars": [
{"name": "SC_1", "type": "Integer"}
]
}
{
"scalars": [
{"name": "SC_r", "type": "Integer", "value": "10"}
]
}