SQL and triangles?
Funny little SQL exercise
I have started using hackerrank.com since a couple of months and I really like it. The website provides cool exercises and preparation kit for interviews.
I want to propose you a quick exercise from their SQL section that was pretty funny to do: Type of Triangle
You have to determine the type of triangles contained in a table composed by 3 INT columns (a, b, c). Every row maybe is a triangle and the length of its sides is stored in the a, b and c columns.
Our maybe triangles can be:
- Equilateral Triangle: all of its sides have equal length
- Isosceles Triangle: 2 of its sides have equal length
- Scalene Triangle: all sides have different length
- Not A Triangle: if the sum of two sides is less than the third one
Before looking at my solution try to do it yourself!
Outro
I hope the story was interesting and thank you for taking the time to read it. Just to be clear I do not have any commercial affiliation with hackerrank.com. On my Blogspot you can find the same post in Italian. Let me know if you have any question and if you like the content that I create feel free to buy me a coffee.