Type of Triangle - CASE END를 활용해야 합니다.
Write a query identifying the type of each record in the TRIANGLES table using its three side lengths.
- 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
SELECT
CASE
WHEN A = B AND B = C THEN 'Equilateral'
WHEN A >=B+C OR B>=A+C OR C>=A+B THEN 'Not A Triangle'
WHEN A = B OR A = C OR B = C THEN 'Isosceles'
ELSE 'Scalene'
END
FROM TRIANGLES
댓글