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
Your answer is actually right. But the one little information (Triangle's 'Right' Definition) is missing on the question (which is not your fault) that if two sides' sum is bigger OR EQUAL to another side then it's not a triangle
The only thing you should do is putting '=' near of your '<'
select
case
when A+B <= C or A+C <= B or B+C <= A then "Not A Triangle"
when A=B and B=C then "Equilateral"
when A=B or A=C or B=C then "Isosceles"
when A<>B and B<>C then "Scalene"
end as triangles_type
from TRIANGLES;
MySQL With All Test Case Passed:-
SELECT CASE
WHEN A + B > C AND A+C>B AND B+C>A THEN CASE
WHEN A = B AND B = C THEN 'Equilateral'
WHEN A = B OR B = C OR A = C THEN 'Isosceles'
WHEN A != B OR B != C OR A != C THEN 'Scalene'
END ELSE 'Not A Triangle' END FROM TRIANGLES;
SELECT
CASE
WHEN A + B <= C or A + C <= B or B + C <= A THEN 'Not A Triangle'
WHEN A = B and B = C THEN 'Equilateral'
WHEN A = B or A = C or B = C THEN 'Isosceles'
WHEN A <> B and B <> C THEN 'Scalene'
END tuple
FROM TRIANGLES;
select case
when A+B <= C or A+C <= B or B+C <= A then "Not A Triangle"
when A=B and B=C then "Equilateral"
when A=B or A=C or B=C then "Isosceles"
else "Scalene"
end as triangles_type
from TRIANGLES;
select
case
when (a+b>c) and (b+c>a) and (c+a>b) then
case
when a=b and b=c then 'Equilateral'
when a=b or b=c or c=a then 'Isosceles'
else 'Scalene'
end
else 'Not A Triangle'
end
from triangles;
For Oracle 11g this is working:
SELECT CASE WHEN A+B>C then case when A=B AND B=C THEN 'Equilateral'
WHEN A=B OR B=C OR A=C THEN 'Isosceles'
WHEN A!=B or B!=C OR A!=C THEN 'Scalene' END
ELSE 'Not A Triangle' END
FROM TRIANGLES;