

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.
세 변의 길이를 사용하여 TRIANGLES 테이블의 각 레코드 유형을 출력하시오.
Equilateral(정삼각형): 세 변의 길이가 같다.Isosceles(이등변삼각형): 두 변의 길이가 같다.Scalene(부등변삼각형): 세 변의 길이가 모두 다르다.Not A Triangle(삼각형이 아니다): A, B, C는 삼각형을 형성하지 않는다.Values in the tuple
(20, 20, 23)form an Isosceles triangle, becauseA = B
(20, 20, 23)은 A ≡ B이기 때문에 Isosceles triangle(이등변삼각형)이다.
Values in the tuple
(20, 20, 20)form an Equilateral triangle, becauseA = B = C.
(20, 20, 20)은 A = B = C이기 때문에 Equilateral triangle(정삼각형)이다.
Values in the tuple
(20, 21, 22)form a Scalene triangle, becauseA ≠ B ≠ C.
(20, 21, 22)은 A ≠ B ≠ C이기 때문에 Scalene triangle(부등변삼각형)이다.
Values in the tuple
(13, 14, 30)cannot form a triangle because the combined value of sides and is not larger than that of side .
(13, 14, 30)은 A + B 값이 C보다 크지 않기 때문에 Not A 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;
문제 이해를 돕기 위한 예시를 잘 참고하여 코드를 작성하면 된다.Scalene를 먼저 코드로 작성하게 되면 Not A Triangle인 경우가 잘못 판단될 수 있으므로 위와 같이 Not A Triangle인 경우를 먼저 검사해줘야 한다.