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
|
3133 Discussions
|
Please Login in order to post a comment
MySQL 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 B = C OR A = C THEN 'Isosceles' ELSE 'Scalene' END AS triangle_type 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 AND C = A THEN 'Equilateral' WHEN A = B OR B = C OR C = A THEN 'Isosceles' WHEN A!=B and B!=C and C!=A THEN 'Scalene' END FROM TRIANGLES;
SELECT CASE -- Check if it is not a triangle first WHEN A + B <= C OR B + C <= A OR A + C <= B THEN 'Not A Triangle' -- Check if it is Equilateral WHEN A = B AND B = C THEN 'Equilateral' -- Check if it is Isosceles WHEN A = B OR B = C OR A = C THEN 'Isosceles' -- Check if it is Scalene WHEN A != B AND B != C AND A != C THEN 'Scalene' END AS type FROM TRIANGLES;
-- MS SQL Server select case when ((t.A+t.B)<=t.C) or ((t.A+t.C)<=t.B) or ((t.B+t.C)<=t.A) then 'Not A Triangle' else case when (t.A = t.B) and (t.A = t.C) then 'Equilateral' else case when (t.A = t.B) or (t.A=t.C) or (t.C=t.B) then 'Isosceles' else 'Scalene ' end end end from TRIANGLES as t
select case when A+B<=C or B+C<=A or A+C<=B then "Not A Triangle" when A=B and B=C and C=A then "Equilateral" when A=B or B=C or C=A then "Isosceles" when A!=B and B!=C and C!=A then "Scalene" end from triangles;