Type of Triangle in MYSQL

前端 未结 18 2383
执念已碎
执念已碎 2020-12-09 11:48

Problem statement:

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the followin

18条回答
  •  萌比男神i
    2020-12-09 12:35

       select case
    when (A+B<=C or B+C<=A or A+C<=B) then 'Not A Triangle'
    when (A=B and B=c) then 'Equilateral'
    when (A=B AND C<>B)or(B=C AND C<>A)or(A=C AND A<>B) then 'Isosceles'
    else 'Scalene'
    end as triangle_type
    from TRIANGLES;
    

    here, it will strictly check for the type of the triangles.

提交回复
热议问题