https://www.hackerrank.com/challenges/what-type-of-triangle
SELECT CASE
WHEN A = B AND B = C THEN 'Equilateral'
WHEN A + B <= C OR A + C <= B OR B + C <= A THEN 'Not A Triangle'
WHEN A = B OR B = C OR A = C THEN 'Isosceles'
ELSE 'Scalene'
END
FROM triangles
이렇게도 풀 수 있다.
SELECT CASE
WHEN A + B > C AND B + C > A AND A + C > B THEN
CASE
WHEN A = B AND B = C THEN 'Equilateral'
WHEN A = B OR B = C OR A = C THEN 'Isosceles'
ELSE 'Scalene'
END
ELSE 'Not A Triangle'
END
FROM triangles