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
SELECT CASE
WHEN A+B>C AND B+C>A AND A+C>B THEN
CASE
WHEN A=B AND B=C THEN 'Equilateral'
WHEN A=B or A=C OR B=C THEN 'Isosceles'
ELSE 'Scalene'
END
ELSE 'Not A Triangle'
END
FROM TRIANGLES
Step 1: First we select case to check if given input is a triangle or not
Step 2: If it is a triangle then check for its type. So first case if all sides are the same, then the triangle type is 'Equilateral'
, then second case if any two sides are the same then the triangle type is 'Isosceles'
, otherwise the triangle type is 'Scalene'
.