我想在使用管道分隔符的select查询中将列名及其值硬编码为New York
。例如。 Emp
表格包含EmpId
,EmpName
,Salary
列。我想要输出,如
Select EmpId ||'|'||
EmpName ||'|'||
'NewYork' as City ||'|'||
Salary
from Emp
此处我想在输出查询中使用City
列,并且每个记录的值应为'NewYork'
。
我在这里收到错误"FROM keyword not found where expected"
。当我使用逗号而不是管道分隔符时,我得到的结果却没有使用Pipe。请指教。提前谢谢。
答案 0 :(得分:0)
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;