DB/SQL

Type of Triangle

_S0_H2_ 2020. 6. 19. 01:09
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
반응형