-1

我想硬编码列名及其值,就像New York在带有管道分隔符的选择查询中一样。例如,Emp表有列EmpId, EmpName, Salary。我想要输出,例如

Select EmpId ||'|'||
       EmpName ||'|'||
       'NewYork' as City  ||'|'||
       Salary
 from Emp

这里我想要City输出查询中的列,它的值应该是'NewYork'每条记录。

在这里我收到错误"FROM keyword not found where expected"。当我使用逗号而不是管道分隔符时,我得到了结果,但没有使用管道。请指教。提前致谢。

4

1 回答 1

2
with emps as (
  select 1 as id, 'Smith' as name, 2000 as salary from dual
  union
  select 2, 'Jones', 2200 from dual
)
select
  id || '|' || name as record1,
  id || '|' || name || '|NewYork|' || salary as record2,
  'NewYork' as city
from emps;
于 2013-08-12T05:54:22.337 回答