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
|
3403 Discussions
|
Please Login in order to post a comment
I wrote this but its throwing error select case When (a=b AND b=c) then "Equilateral" when (a=b AND b<>c) OR (a=c AND a<>b) OR (b=c AND a<>b) then "Isosceles" when (a<>b AND b<>c AND a<>c AND(a+b>c AND a+c>b AND b+c>a)) then "Scalene" else "Not A Triangle" end AS result from Triangles;
select Case when A+B>C and A=B and B=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 and B<>C then 'Scalene' else 'Not A Triangle' End Result from TRIANGLES
SELECT CASE WHEN (A + B <= C) OR (A + C <= B) OR (B + C <= A) THEN "Not A Triangle" WHEN (A = B) AND (A = C) AND (B = C) THEN "Equilateral" WHEN (A = B) OR (B = C) OR (A = C) THEN "Isosceles" WHEN (A != B) AND (A != C) AND (B != C) THEN "Scalene" END AS triangletype FROM TRIANGLES
SELECT CASE WHEN (A+B>C AND B+C>A AND A+C>B) THEN (CASE WHEN A=B AND B=C AND A=C THEN 'Equilateral' WHEN A=B OR A=C OR B=C THEN 'Isosceles' ELSE 'Scalene' END) ELSE 'Not A Triangle' END from TRIANGLES; [I have checked the triangle condition first and then when on checking the sides of the triangle conditions].