-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathType of Triangle.sql
More file actions
22 lines (20 loc) · 877 Bytes
/
Type of Triangle.sql
File metadata and controls
22 lines (20 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
Enter your query here.
Please append a semicolon ";" at the end of the query and enter your query in a single line to avoid error.
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 3 sides of equal length.
Isosceles: It's a triangle with 2 sides of equal length.
Scalene: It's a triangle with 3 sides of differing lengths.
Not A Triangle: The given values of A, B, and C don't form a triangle.
*/
SELECT CASE
WHEN A + B > C AND B + C > A AND C + A > B THEN
CASE
WHEN A = B AND B = C THEN 'Equilateral'
WHEN A = B OR B = C OR C = A THEN 'Isosceles'
ELSE 'Scalene'
END
ELSE
'Not A Triangle'
END
FROM TRIANGLES;