Skip to content

Commit 3ab8812

Browse files
authored
EASY
1 parent 042604e commit 3ab8812

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

610. Triangle Judgement.sql

+47
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
1+
-- Problem:
2+
3+
/*
4+
Table: Triangle
5+
6+
+-------------+------+
7+
| Column Name | Type |
8+
+-------------+------+
9+
| x | int |
10+
| y | int |
11+
| z | int |
12+
+-------------+------+
13+
In SQL, (x, y, z) is the primary key column for this table.
14+
Each row of this table contains the lengths of three line segments.
15+
16+
17+
Report for every three line segments whether they can form a triangle.
18+
19+
Return the result table in any order.
20+
21+
The result format is in the following example.
22+
23+
24+
25+
Example 1:
26+
27+
Input:
28+
Triangle table:
29+
+----+----+----+
30+
| x | y | z |
31+
+----+----+----+
32+
| 13 | 15 | 30 |
33+
| 10 | 20 | 15 |
34+
+----+----+----+
35+
Output:
36+
+----+----+----+----------+
37+
| x | y | z | triangle |
38+
+----+----+----+----------+
39+
| 13 | 15 | 30 | No |
40+
| 10 | 20 | 15 | Yes |
41+
+----+----+----+----------+
42+
*/
43+
44+
-------------------------------------------------------------------------------
45+
46+
-- Solution:
47+
148
SELECT x,y,z,(
249
CASE
350
WHEN x+y>z AND x+z>y AND y+z>x THEN 'Yes'

0 commit comments

Comments
 (0)