Friday, January 6, 2017

posgresql select case

Just to help if anyone stumble on this question like me, if you want to use if in PostgreSQL, you use "CASE"
select 
    case
        when stage = 1 then 'running'
        when stage = 2 then 'done'
        when stage = 3 then 'stopped'
    else 
        'not running'
    end as run_status from processes

No comments:

Post a Comment