04pallav
9/13/2017 - 9:54 PM

CASE IF ELSE

CASE IF ELSE

select case WHEN A+B<=C OR B+C<=A OR C+A<=B THEN 'Not A Triangle'
            when A=B AND B=C then 'Equilateral'
            when A=B OR B=C OR C=A then 'Isosceles'
            ELSE 'Scalene'
             end as newColumn
from ( SELECT A,B,C FROM TRIANGLES) M

SELECT name, population
      ,CASE WHEN population<1000000 
            THEN 'small'
            WHEN population<10000000 
            THEN 'medium'
            ELSE 'large'
       END
  FROM bbc






select case when cond then ans when cond then ans else ans end from table