We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

select
case
when A+B > C AND A=B AND B=C AND A=C
then 'Equilateral'
when A+B > C AND A=B OR B=C OR A=C
then 'Isosceles'
when A+B > C AND A!=B
then 'Scalene'
else
'Not A Triangle'
End
from TRIANGLES

if "Case1: A + B > C AND A+C>B AND B+C>A" is true then only after that you have to verify "case2: A != B OR B != C OR A != C" which kind of triangle it is. If it is not a valid triangle, case1 will be false and you don't have to worry about the rest cases.

## Type of Triangle

You are viewing a single comment's thread. Return to all comments →

A != B OR B != C OR A != C also can be not triangle

(3, 4, 5) is a triangle, but (3, 4, 50) is not.

but this fails in the first condition in the query CASE WHEN A + B > C AND A+C>B AND B+C>A so the query is correct

select case when A+B > C AND A=B AND B=C AND A=C then 'Equilateral' when A+B > C AND A=B OR B=C OR A=C then 'Isosceles' when A+B > C AND A!=B then 'Scalene' else 'Not A Triangle' End from TRIANGLES

TRY THIS.........

IF (A,B,C)= (20,1,1) then foolow your code the result will be "Isosceles'

But in fact this is not a triangle because A< B+C So the point is you forget the condition B+C>A AND A+C>B

But i wonder why the code is accepted in this case

I dont understand your meaning, it says in every sub that A+B>C

if "Case1: A + B > C AND A+C>B AND B+C>A" is true then only after that you have to verify "case2: A != B OR B != C OR A != C" which kind of triangle it is. If it is not a valid triangle, case1 will be false and you don't have to worry about the rest cases.

that is the raason he gave when A+B>c;

no, it is the case of a scalene triangle. but a case where A+B

A!=B AND B!=C I think this would work

check in example it is scalene type