Sales Person
Problem
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.
Solution
The problem Sales Person
can be solved by checking for the property of a triangle where the sum of the length of any two sides of a triangle is greater than the length of the third side.
Implementation
# Write your MySQL query statement below
SELECT x, y, z, IF(GREATEST(x, y, z) < LEAST(x + y, y + z, z + x), 'Yes', 'No') AS triangle
FROM triangle;