Skip to content

1440. Evaluate Boolean Expression 👍

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
SELECT Expressions.*,
  (
    CASE
      WHEN Expressions.operator = '<'
      AND LeftOperand.value < RightOperand.value THEN 'true'
      WHEN Expressions.operator = '>'
      AND LeftOperand.value > RightOperand.value THEN 'true'
      WHEN Expressions.operator = '='
      AND LeftOperand.value = RightOperand.value THEN 'true'
      ELSE 'false'
    END
  ) AS value
FROM Expressions
INNER JOIN VARIABLES AS LeftOperand
  ON (Expressions.left_operand = LeftOperand.name)
INNER JOIN VARIABLES AS RightOperand
  ON (Expressions.right_operand = RightOperand.name);