如何使用SQL query
语句为CASE
中的多个列分配值。当我尝试如下所示时,出现错误。
select case when 1=1 then 'Y' column1, 'Yes' column2 end from dual;
ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action:
Error at Line: 24 Column: 31
请您帮忙。
重复case
:
SQL> select case when 1 = 1 then 'Y'
2 else 'N'
3 end column1,
4 --
5 case when 1 = 1 then 'Y'
6 else 'N'
7 end column2
8 from dual;
C C
- -
Y Y
SQL>
也许你想要:
select 'Y' as column1, 'Yes' as column1
from dual
where 1=1
union all
select NULL, NULL
from dual
where not (1=1);