삼각형의 조건을 열심히 생각하며 풀었던 문제.
코드만 보면 굉장히 간단한데, 이등변삼각형의 조건이나 조건들 간의 우선순위를 생각하느라 예상보다 시간이 은근 걸렸다.
여기서 기억해야 할 점은 When절을 써주는 순서를 잘 생각해야 한다는 것!
정삼각형이 두 번째 조건에 해당되지만, 이미 위에서 정삼각형이 해당되는 조건을 정의해버렸으므로 필터링이 되었고, 코드상에서 두 번째 조건을 맨 마지막에 썼다가 계속 오답을 제출했다.
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:
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 c = a then 'Isosceles'
else 'Scalene'
end
from TRIANGLES