본문 바로가기
DB/SQL

Type of Triangle

by _S0_H2_ 2020. 6. 19.
728x90
반응형

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.

 

select if(A+B<=C or B+C<=A or A+C<=B,'Not A Triangle',
        if(A=B and B=C,'Equilateral',
        if(A=B or B=C or A=C,'Isosceles','Scalene'))) 
from TRIANGLES as T;
Equilateral 
Equilateral 
Isosceles 
Equilateral 
Isosceles 
Equilateral 
Scalene 
Not A Triangle 
Scalene 
Scalene 
Scalene 
Not A Triangle 
Not A Triangle 
Scalene 
Equilateral
728x90
반응형

'DB > SQL' 카테고리의 다른 글

Employee Salaries  (0) 2020.06.19
Employee Names  (0) 2020.06.19
Higher Than 75 Marks  (0) 2020.06.19
HackerRank_16. Weather Observation Station 10  (0) 2020.06.12
HackerRank_15. Weather Observation Station 9  (0) 2020.06.11