文章目录
-
- 原题题目
- 代码实现(首刷学习 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