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
'언어 & 라이브러리 > SQL' 카테고리의 다른 글
해커랭크 HackerRank Binary Tree Nodes Advanced Select (0) | 2022.01.19 |
---|---|
해커랭크 HackerRank The PADS Advanced Select (0) | 2022.01.19 |
SQLZOO SELECT BASIC 문제 풀이 (0) | 2022.01.19 |
해커랭크 HackerRank The Report Basic Join (0) | 2022.01.19 |
해커랭크 Hackerrank SQL BASIC Select 문제풀이 (0) | 2022.01.19 |
댓글