31 January 2018

Type of Triangle

My solution:
SELECT IF(( A + B > C 
            AND ABS(A - B) < C ) 
          AND ( A + C > B 
                AND ABS(A - C) < B ) 
          AND ( B + C > A 
                AND ABS(B - C) < A ), IF (A = B 
                                          AND A = C 
                                          AND B = C, "Equilateral", 
                                      IF(A = B 
                                          OR B = C 
                                          OR A = C, "Isosceles", "Scalene")), 
              "Not A Triangle") 
FROM   TRIANGLES;