← case operator page · conditional/case/sc/false_condition_gives_else_operand

False condition gives else operand 🟢 all ok

pandas ✅ · DuckDB ✅

Tests:

case when SC_1 > SC_2 then 2 else 5 with SC_1 = 0 and SC_2 = 3: one when, with a false condition.

Manual:

Case: "The case operator returns the first thenOperand whose corresponding condition evaluates to true, elseOperand if none of the when conditions evaluates to true."

Expected:

SC_r = 5, an Integer: SC_1 > SC_2, that is 0 > 3, is false and there is no other when, so the result is the elseOperand.

script.vtl ⇩

SC_r := case when SC_1 > SC_2 then 2 else 5;

input/scalars.csv ⇩

SC_1SC_2
03

input/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_1", "type": "Integer"},
    {"name": "SC_2", "type": "Integer"}
  ]
}

expected/scalars.json ⇩

{
  "scalars": [
    {"name": "SC_r", "type": "Integer", "value": "5"}
  ]
}