- 选择型
- 简单case表达式
--选择型case
CASE
WHEN C1 THEN E1
WHEN C2 THEN E2
[ELSE ED]
END
--选择型
SELECT
CASE
WHEN A < 1 THEN
(SELECT 1 FROM DUAL)
WHEN B > 4 THEN
(SELECT 2 FROM DUAL)
WHEN C = 4 THEN
(SELECT "C IS 3" C FROM DUAL)
ELSE
'UKNOW'
END re
FROM
(SELECT 1 A, 2 B, 3 C) aa;
-- 简单性
SELECT
CASE A
WHEN 1 THEN
(SELECT 1 FROM DUAL)
WHEN 2 THEN
(SELECT 2 FROM DUAL)
WHEN 3 THEN
(SELECT 3 FROM DUAL)
END re
FROM
(SELECT 1 A, 2 B, 3 C) aa;
一般选择型最灵活,推荐使用选择型