Oracle和MySQL通用(类似于if(){}else if(){}else{})
等值
SELECT 列名,
CASE 列名
WHEN ‘列值‘ THEN ‘转换值‘
......
WHEN ‘列值‘ THEN ‘转换值‘
[ELSE ‘转换值‘]
END [ AS 别名]
FROM tableName;
范围
SELECT 列名,
CASE
WHEN 列名>3000 THEN ‘转换值‘
......
WHEN 列名>1500 THEN ‘转换值‘
[ELSE ‘转换值‘]
END [ AS 别名]
FROM tableName;
ps:按照格式手动敲,复制粘贴会有空字符格式问题。