CASE WHEN
1.对值判断
2.条件判断
--方式一: 对值判断
SELECT
CASE
指定字段
WHEN 条件值1 THEN
结果1
WHEN 条件值2 THEN
结果2
WHEN 条件值3 THEN
结果3
ELSE 默认值
END 字段别名
FROM
表名
SELECT
CASE
STATUS
WHEN 0 THEN
'等待'
WHEN 1 THEN
'成功'
WHEN 2 THEN
'失败'
END STATUS
FROM
SYS_USER
-- 方式二: 判断条件
SELECT
CASE
WHEN 条件1 THEN
结果1
WHEN 条件2 THEN
结果2
WHEN 条件3 THEN
结果3
ELSE 默认结果
END 字段别名
FROM
表名
SELECT
CASE
WHEN SETTLE_MONEY<=1000 THEN
'低价'
WHEN SETTLE_MONEY > 1000 AND SETTLE_MONEY <=2000 THEN
'普通'
WHEN SETTLE_MONEY > 2000 THEN
'高价'
ELSE ''
END type
FROM
ORDER_INFO
标签:case,CASE,END,when,WHEN,ELSE,&&,条件,SELECT
From: https://blog.51cto.com/u_16085354/6411715