0

希望能够根据选择结果在 sql*plus 中显示条件列标题。A_DATE因此,在下面的示例中,如果值为,则希望显示标题Abegin/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,
4

1 回答 1

1

I don't think so. If the query returned more than one row you run the risk of ambiguity. You could return two columns though. Something like this:

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"
于 2013-09-26T01:35:02.087 回答