concat撇号到oracle sql查询

时间:2013-03-04 00:03:45

标签: sql concat apostrophe

大家好我正在寻找一些关于如何在我的第一列上添加撇号到查询结果的指示。

我当前的查询:

set verify off
set colsep "',"
set pagesize 2000
ALTER SESSION SET NLS_DATE_FORMAT='DD-MON-YY-HH24:MI:SS';
spool /home/user/out.txt

select '[' || table1.collectdatetime as "['Date-Time",table1.cycletime as "'Time'" from table1 where interfacename='somename' and collectdatetime > (CURRENT_DATE - 1)
order by collectdatetime ASC;

结果如何:

['Date-Time        ','InCycleTime'
-------------------',-------------
[02-MAR-13-17:56:16',           29

我喜欢的是让结果返回并在[

之后]添加撇号
['Date-Time        ','InCycleTime'
-------------------',-------------
['02-MAR-13-17:56:16',           29

这是针对oracle 11.1.0.7构建的。正在查询和解析数据,但我需要解决撇号问题。

1 个答案:

答案 0 :(得分:0)

使用它:

select '[''' || table1.collectdatetime as "['Date-Time",table1.cycletime as "'Time'" from table1 where interfacename='somename' and collectdatetime > (CURRENT_DATE - 1)
order by collectdatetime ASC;