Type of Triangle in MYSQL

前端 未结 18 2387
执念已碎
执念已碎 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条回答
  •  眼角桃花
    2020-12-09 12:18

    For MySQL:

    select
      case
          when (a+b>c) and (a+c>b) and (b+c>a) then
               case
                  when (a=b) and (b=c) and (a=c) then 'Equilateral'
                  when (a=b) or (b=c) or (a=c) then 'Isosceles'
                  else 'Scalene'
               end
           else 'Not A Triangle'
        end    
    from TRIANGLES 
    

提交回复
热议问题