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 sides of equal length.
Isosceles: It's a triangle with sides of equal length.
Scalene: It's a triangle with sides of differing lengths.
Not A Triangle: The given values of A, B, and C don't form a triangle.
Input Format
The TRIANGLES table is described as follows:
Each row in the table denotes the lengths of each of a triangle's three sides.
Input Format
The TRIANGLES table is described as follows:
Sample Input
Sample Output
Isosceles
Equilateral
Scalene
Not A Triangle
삼각형의 성립조건을 알아야한다
- CASE~WHEN~THEN~ELSE~END
: WHEN 조건은 맨 위의 조건이 먼저 적용된다. 즉 위의 조건에 만족시킨 것은 중복적으로 아래쪽에 적용되지 않는다.
SELECT CASE
WHEN A=B AND B=C THEN 'Equilateral'
WHEN A+B<=C OR A+C<=B OR C+B<=A THEN 'Not A Triangle'
WHEN A=B OR B=C OR C=A THEN 'Isosceles'
ELSE 'Scalene'
END
FROM TRIANGLES