当前位置: 代码迷 >> 综合 >> Leetcode Mysql 1440. 计算布尔表达式的值(DAY 15)
  详细解决方案

Leetcode Mysql 1440. 计算布尔表达式的值(DAY 15)

热度:95   发布时间:2023-11-17 16:55:50.0

文章目录

    • 原题题目
    • 代码实现(首刷学习 CASE)


原题题目


在这里插入图片描述


代码实现(首刷学习 CASE)


# Write your MySQL query statement below
SELECT e.*, (CASE WHEN operator = '>' AND v1.value <= v2.value THEN 'false'WHEN operator = '<' AND v1.value >= v2.value THEN 'false'WHEN operator = '=' AND v1.value <> v2.value THEN 'false'ELSE 'true' END) AS value
FROM expressions AS e
LEFT JOIN variables AS v1 ON e.left_operand = v1.name
LEFT JOIN variables AS v2 ON e.right_operand = v2.name
  相关解决方案