Reputation: 127
Would like to be able to display a conditional column heading, based on the select results, in sql*plus. So in example below, would like to display A_DATE
header if value is A
, or the begin/end_date column
heading otherwise:
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,
Upvotes: 0
Views: 258
Reputation: 20804
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"
Upvotes: 1