希望能够在sql * plus中根据选择结果显示条件列标题。因此,在下面的示例中,如果值为A_DATE
,则显示A
标头,否则显示begin/end_date column
标题:
SELECT
CASE thingy
WHEN 'A' THEN TO_CHAR(a_date, 'DD-MON-YYYY') "A_DATE"
ELSE TO_CHAR(begin_date, 'DD-MON-YYYY') || ' '
|| TO_CHAR(end_date, 'DD-MON-YYYY') "BEGIN_DATE END_DATE"
END,
答案 0 :(得分:1)
我不这么认为。如果查询返回多行,则存在歧义的风险。你可以返回两列。像这样:
select case when my condition is met then myfield else null end "true column"
, case when my my condition is not met then myfield else null end "false column"