- Prepare
- SQL
- Advanced Select
- Type of Triangle
- Discussions
Type of Triangle
Type of Triangle
+ 1 comment when more than one condition use cases
select case WHEN A=B AND B=C THEN 'Equilateral' WHEN A + B <= C OR A + C <= B OR B + C <= A THEN 'Not A Triangle' WHEN A = B OR B = C OR A = C THEN 'Isosceles' WHEN A <> B AND A <> C AND B <> C THEN 'Scalene' end 'triangle type' from TRIANGLES
+ 1 comment What's wrong here? :'(
select (case when a = b and b = c then 'Equilateral' when a = b or b = c or a = c then 'Isosceles' when a <> b and b <> c and a <> c then 'Scalene' when a + b <= c or b + c <= a or a + c <= b then 'Not A Triangle' end) from triangles;
+ 0 comments select case when a+b <= c or a+c <= b or b+c <= a then 'not a triangle' when a= b or b= c or c= a then 'isosceles' when a = b and b = c and c = a then 'equilateral' when a != b and B != c and a != c then 'Scalene' end from triangles;
whats wrong with query??? pls help
+ 0 comments SELECT CASE WHEN A = B AND B = C THEN 'Equilateral' 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 'Scalene' WHEN A = B OR B = C OR A = C THEN 'Isosceles' END AS triangle_type FROM triangles;
+ 1 comment 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 c= a then 'isosceles' when a != b and B != c and a != c then 'Scalene' end from triangles; my output is same as the expected one but why it is till wrong?
Sort 2311 Discussions, By:
Please Login in order to post a comment