
이때 문제의 조건 A,B,C는 삼각형 변의 길이를 의미한다. (A<B<C)

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:
Equilateral: It's a triangle with 3 sides of equal length.
Isosceles: It's a triangle with 2 sides of equal length.
Scalene: It's a triangle with 3 sides of differing lengths.
Not A Triangle: The given values of A, B, and C don't form a triangle.
이 문제는 easy난이도이지만 생각보다 어렵다. 주어진 조건을 잘 읽어봐야된다. 삼각형의 길이가 a,b,c 칼럼에 값으로 주어져 있는데 C가 가장 큰 값이므로 삼각형의 결정조건을 따질때 A+B <= C 이면 삼각형 조건에 만족하지 않는다. 부끄럽지만 등호조건을 빼먹어서 정답을 출력하는데 시간낭비하고 말았다.
case문에서 위의 조건이 가장 우선시된다. 즉 모든 조건을 만족할때 맨 위의 조건을 적용한다.
SELECT CASE
WHEN A=B AND A=C THEN 'Equilateral'
WHEN (A=B OR A=C OR B=C) AND A+B>C THEN 'Isosceles'
WHEN A+B>C THEN 'Scalene'
ElSE 'Not A Triangle'
END AS type
FROM TRIANGLES