A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. However, this assignment is very heavy because there are hundreds of records to calculate.Could you help Tim by writing a query to judge whether these three sides can form a triangle, assuming table triangle holds the length of the three sides x, y and z.xyz131530102015For the sample data above, your query should return the follow result:xyztriangle131530No102015yesOptionsselect case when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as trianglefrom triangle ;select x, y, z, case when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as trianglefrom triangle ;select x, y, z, when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as trianglefrom triangle ;select x, y, z, case when x + y > z and x + z > y and y + z > x then 'Yes' end as trianglefrom triangle ;
Question
A pupil Tim gets homework to identify whether three line segments could possibly form a triangle. However, this assignment is very heavy because there are hundreds of records to calculate.Could you help Tim by writing a query to judge whether these three sides can form a triangle, assuming table triangle holds the length of the three sides x, y and z.xyz131530102015For the sample data above, your query should return the follow result:xyztriangle131530No102015yesOptionsselect case when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as trianglefrom triangle ;select x, y, z, case when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as trianglefrom triangle ;select x, y, z, when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as trianglefrom triangle ;select x, y, z, case when x + y > z and x + z > y and y + z > x then 'Yes' end as trianglefrom triangle ;
Solution
The correct option is:
select x, y, z, case when x + y > z and x + z > y and y + z > x then 'Yes' else 'No' end as triangle from triangle;
This SQL query will select all records from the 'triangle' table and add a new column 'triangle' to the result. This new column will contain 'Yes' if the three sides can form a triangle (i.e., the sum of the lengths of any two sides is greater than the length of the third side) and 'No' otherwise.
Similar Questions
Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:Equilateral: It's a triangle with sides of equal length.Isosceles: It's a triangle with sides of equal length.Scalene: It's a triangle with sides of differing lengths.Not A Triangle: The given values of A, B, and C don't form a triangle.Input FormatThe TRIANGLES table is described as follows:
Get the lengths of three sides of a triangle. Check whether the triangle can be formed or not. If possible then classify the triangle as equilateral, isosceles or scalene. If unable to form the triangle (the sum of the lengths of any two sides of a triangle must be greater than the length of the third side) print error. An equilateral triangle is a type of triangle that has all three sides of equal length.An isosceles triangle is a type of triangle that has at least two sides of equal length.A scalene triangle is a type of triangle that has all three sides of different lengths.Testcases:Input:444Output: Equilateral triangleInput:5710Output: Scalene triangleInput:249Output: ErrorInput:575Output: Isosceles triangle
or each set of three lengths, determine if they can be the side lengths of a triangle.Lengths Can be side lengths of a triangle Cannot be side lengths of a triangle, 18, 610 , 9.1, 3.56.3 , 7, 724 , 14, 73
A/n ______ triangle, is a triangle with exactly three sides of equal length.
Construction of a triangle is not possible if :
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.