610. Triangle Judgement
SQL 50 · Advanced Select and Joins (day 5). Decode it with the hints, solve it on LeetCode, then compare with the reference solution in MySQLPostgreSQL.
Your work
Hints
Open one at a time. Try to finish with as few as you can.
1. What does one output row represent?
One row of x, y, z.
2. Approach
CASE WHEN all three sum checks pass THEN 'Yes' ELSE 'No'.
3. The trap
All three inequalities, strictly greater.
Reference solution
Tested on MySQL 8.0 and PostgreSQL 16. Switch dialect at the top of the page.
Show the MySQLPostgreSQL solution
SELECT x, y, z,
CASE WHEN x + y > z AND x + z > y AND y + z > x
THEN 'Yes' ELSE 'No' END AS triangle
FROM Triangle;