Last active
October 26, 2019 09:22
-
-
Save HaiBV/23bb9df710db280110d4643f50be402b to your computer and use it in GitHub Desktop.
typeOfTriangle.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 Format
The TRIANGLES table is described as follows:
CREATE TABLE TRIANGLES ( A INT(6), B INT(6), C INT(6) )
Each row in the table denotes the lengths of each of a triangle's three sides.