【SQL】610. 判断三角形 (case when... + if )

在这里插入图片描述
在这里插入图片描述

思路: 三角形任意两边之和大于第三边,任意两边之差小于第三边。

写法一

select x, y, z, 
    (case when x+y>z and x+z>y and y+z>x then 'Yes' else 'No' end) as triangle
from Triangle

写法二

select x, y, z, if(x+y<=z or x+z<=y or y+z<=x, 'No', 'Yes') as triangle
from Triangle

猜你喜欢

转载自blog.csdn.net/xiaoyue_/article/details/129946664
今日推荐