How to transform SELECT output column to arbitrary value based on this column?

postgresql, sql

Solution

Use a `CASE` statement:

select type,
       case
         when type = 'type1' then 'modifiedType1'
         when type = 'type2' then 'modifiedType2'
         else type
       end as modifiedType
from the_table
WHERE type in ('type1', 'type2')

Btw: `type` is not a good name for a column

Problem

For now I have following query: ``` SELECT "type" AS "modifiedType" FROM "Table" WHERE "type" = 'type1' OR "type" = 'type2' ``` What I want is to return `modifiedType` like this: ``` if "type" = 'type1' then 'modifiedType1' else if "type" = 'type2' then 'modifiedType2' ``` So I just want to modify column value with another value based on original column value. Type column in `ENUM` not string. I am using Postgres 9.3 (or 9.4?).

Original source