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.
- Prepare
- SQL
- Advanced Select
- Type of Triangle
- Discussions
Type of Triangle
Type of Triangle
Sort by
recency
|
3321 Discussions
|
Please Login in order to post a comment
SELECT CASE WHEN a + b <= c or b + c <= a or a + c <= b THEN "Not A Triangle" WHEN a = b and b = c THEN "Equilateral" WHEN a = b or b = c or a = c THEN "Isosceles" ELSE "Scalene" END from Triangles;
Can anyone help me understand why this is not an acceptable solution?
SELECT CASE WHEN A+B<=C OR B+C<=A OR A+C<=B THEN 'Not a Triangle' WHEN A=B AND B=C THEN 'Equilateral' WHEN A=B OR B=C OR C=A THEN 'Isosceles' ELSE 'Scalene' END FROM TRIANGLES
SELECT CASE WHEN A + B > C AND A + C > B AND B + C > A THEN -- Check for valid triangle CASE WHEN A = B AND B = C THEN 'Equilateral' WHEN (A = B and B != C) or (A != B and B = C) THEN 'Isosceles' WHEN A != B AND B != C THEN 'Scalene' END ELSE 'Not A Triangle' -- If the sides don't form a valid triangle END AS TriangleType FROM Triangles;
SELECT CASE WHEN (A + B > C AND A + C > B AND B + C > A) THEN CASE WHEN (A=B AND B=C AND C=A) THEN 'Equilateral' WHEN (A=B OR B=C OR C=A) THEN 'Isosceles' ELSE 'Scalene' END ELSE 'Not A Triangle' END FROM TRIANGLES ;