尝试使用它的列在select语句上使用条件。我该怎么写这样的东西?
SELECT * FROM ( CASE (SELECT date_term, e_status
FROM HM
WHERE c_num = 2327
AND e_unique = 'something')
WHEN (date_term) < TRUNC(SYSDATE)
OR (e_status IS NOT NULL OR e_status <> 'A')
THEN (SELECT NULL AS A,
NULL AS B,
NULL AS C,
NULL AS D,
NULL AS E,
NULL AS F
FROM DUAL)
ELSE (SELECT p_val, p_type
FROM I_PARM T
WHERE c_num=2327
)
PIVOT
(
MIN(p_val)
FOR p_type IN ('A1' AS A,
'B2' AS B,
'C3' AS C,
'D4' AS D,
'E5' AS E,
'F6' AS F)
)
END);
我的右括号错误。感谢。
答案 0 :(得分:3)
SELECT case when x.a = 'something' then b.y
else c.z end
FROM X JOIN Y on x.somecol = y.somecol
JOIN Z on x.somecol = z.somecol;
你在问题中的方式是错误使用案例。用适当的列名替换join
条件,因为您似乎从不同的表中选取值。