SQL语句中使用条件逻辑

select name, sal,

case when sal >= 4000 then 'Good'

       when sal <= 2000 then 'Bad'

       else 'Ok'

end as Status

from tablename 

原文地址:https://www.cnblogs.com/lilideng/p/SQL_Case_When.html