case when postgres
snippet in sql

case when postgres

user7798

     CASE 
      WHEN condition_1  THEN result_1
      WHEN condition_2  THEN result_2
      [WHEN ...]
      [ELSE else_result]
END

case when postgres

user8760

CASE WHEN condition THEN result
     [WHEN ...]
     [ELSE result]
END