Sort by

recency

|

3343 Discussions

|

  • + 0 comments
    SELECT
        CASE
            WHEN A+B<=C OR B+C<=A  OR  A+C <= B 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 TriangleType
    FROM
        TRIANGLES;
    
  • + 0 comments

    My Oracle Solution

    SELECT
        CASE 
            WHEN NOT (A+B>C AND B+C>A AND C+A>B)THEN 'Not A Triangle'
            ELSE (
                CASE
                    WHEN (A = B AND B = C) THEN 'Equilateral'
                    WHEN (A = B OR B = C OR A = C) THEN 'Isosceles'
                    ELSE 'Scalene'
                END
                )
        END
    FROM TRIANGLES;
    
  • + 0 comments

    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;

    Try this

  • + 0 comments

    use cursor

    declare contro cursor scroll for select A,B,C from TRIANGLES 
    open contro;
    declare @canh1 int, @canh2 int, @canh3 int;
    fetch next from contro into @canh1,@canh2,@canh3
    while @@fetch_status = 0
    begin 
    if (@canh1 + @canh2 > @canh3) and(@canh1 + @canh3 > @canh2) and(@canh3 + @canh2 > @canh1) begin
        if @canh1 = @canh2 and @canh2 = @canh3 and @canh1 = @canh3
            print 'Equilateral'; 
        else if (@canh1 = @canh2 and @canh1 != @canh3) or (@canh2 = @canh3 and @canh2 != @canh1) or (@canh1 = @canh3 and @canh1 != @canh2)
            print 'Isosceles';
        else
            print 'Scalene';
        end
    else
        print 'Not A Triangle';
        fetch next from contro into @canh1,@canh2,@canh3
    end
    
  • + 0 comments

    select case when A=B and B=C and A=C then "Equilateral" when (A=B or A=C) and B!=C then "Isosceles" when (A+B)>C then "Scalene" when (A+B)