表:Triangle+-------------+------+| Column Name | Type |+-------------+------+| x | int || y | int || z | int |+-------------+------+(x, y, z)是该表的主键列。该表的每一行包含三个线段的长度。写一个SQL查询,每三个线段报告它们是否可以形成一个三角形。以任意顺序返回结果表。查询结果格式如下所示。示例 1:输入:Triangle 表:+----+----+----+| x | y | z |+----+----+----+| 13 | 15 | 30 || 10 | 20 | 15 |+----+----+----+输出:+----+----+----+----------+| x | y | z | triangle |+----+----+----+----------+| 13 | 15 | 30 | No || 10 | 20 | 15 | Yes |+----+----+----+----------+来源:力扣(LeetCode)链接:https://leetcode.cn/problems/triangle-judgement
#测试数据Create table If Not Exists Triangle (x int, y int, z int);insert into Triangle (x, y, z) values ('13', '15', '30');insert into Triangle (x, y, z) values ('10', '20', '15');
selectx,y,z,case when (x+y) > zand (x+z) > yand (y+z) > xthen 'Yes'else 'No' end trianglefrom Triangle;

笔试题合集免费领取方法
方法一:关注公众号【跟强哥学SQL】,回复关键字【力扣】获取链接。
方法二:访问【SQL网】:https://sql.wang/sql-leetcode/sql-exercise
文章转载自跟强哥学SQL,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




