How to Write a Case Statement in PostgreSQL

Case statements are useful when you're reaching for an if statement in your select clause.

    when precipitation = 0 then 'none'
    when precipitation <= 5 then 'little'
    when precipitation > 5 then 'lots'
    else 'unknown'
  end as amount_of_rain
from weather_data;
database icon
Finally, a unified workspace for your SQL development
Get more done, together, with PopSQL and PostgreSQL