Skip to content

Instantly share code, notes, and snippets.

@IndigoW0lf
Created March 30, 2022 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndigoW0lf/883ea9b7213e8229e358268362dc0cf5 to your computer and use it in GitHub Desktop.
Save IndigoW0lf/883ea9b7213e8229e358268362dc0cf5 to your computer and use it in GitHub Desktop.
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 A = C or B = C THEN 'Isosceles'
WHEN A != B and B != C THEN 'Scalene'
END tuple
FROM TRIANGLES;
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment