Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Have a good contributing!
- [586. Customer Placing the Largest Number of Orders](./leetcode/easy/586.%20Customer%20Placing%20the%20Largest%20Number%20of%20Orders.sql)
- [595. Big Countries](./leetcode/easy/595.%20Big%20Countries.sql)
- [596. Classes With at Least 5 Students](./leetcode/easy/596.%20Classes%20With%20at%20Least%205%20Students.sql)
- [610. Triangle Judgement](./leetcode/easy/610.%20Triangle%20Judgement.sql)
2. [Medium](./leetcode/medium/)
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
- [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql)
Expand Down
31 changes: 31 additions & 0 deletions leetcode/easy/610. Triangle Judgement.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Question 610. Triangle Judgement
Link: https://leetcode.com/problems/triangle-judgement/description/

Table: Triangle

+-------------+------+
| Column Name | Type |
+-------------+------+
| x | int |
| y | int |
| z | int |
+-------------+------+
In SQL, (x, y, z) is the primary key column for this table.
Each row of this table contains the lengths of three line segments.


Report for every three line segments whether they can form a triangle.

Return the result table in any order.
*/

SELECT
x,
y,
z,
CASE
WHEN (x + y) > z AND (x + z) > y AND (y + z) > x THEN 'Yes'
ELSE 'No'
END AS is_triangle
FROM Triangle