Skip to content

Commit 1a1cf57

Browse files
committed
Create 610. Triangle Judgement.sql
1 parent 9a83bc8 commit 1a1cf57

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
610. Triangle Judgement
2+
Solved
3+
Easy
4+
Topics
5+
Companies
6+
SQL Schema
7+
Pandas Schema
8+
Table: Triangle
9+
10+
+-------------+------+
11+
| Column Name | Type |
12+
+-------------+------+
13+
| x | int |
14+
| y | int |
15+
| z | int |
16+
+-------------+------+
17+
In SQL, (x, y, z) is the primary key column for this table.
18+
Each row of this table contains the lengths of three line segments.
19+
20+
21+
Report for every three line segments whether they can form a triangle.
22+
23+
Return the result table in any order.
24+
25+
The result format is in the following example.
26+
27+
28+
29+
Example 1:
30+
31+
Input:
32+
Triangle table:
33+
+----+----+----+
34+
| x | y | z |
35+
+----+----+----+
36+
| 13 | 15 | 30 |
37+
| 10 | 20 | 15 |
38+
+----+----+----+
39+
Output:
40+
+----+----+----+----------+
41+
| x | y | z | triangle |
42+
+----+----+----+----------+
43+
| 13 | 15 | 30 | No |
44+
| 10 | 20 | 15 | Yes |
45+
+----+----+----+----------+
46+
47+
48+
# Write your MySQL query statement below
49+
SELECT
50+
*,
51+
IF(x + y > z AND x + z > y AND y + z > x, 'Yes', 'No') AS triangle
52+
FROM Triangle;

0 commit comments

Comments
 (0)