Friday, February 10, 2012

How to use 'case' in mysql query

select id,
    case report.type
        when 'P' then amount

        when 'N' then -amount

    end as amount 
from
    `report`

No comments:

Post a Comment