在 SELECT 查询中返回太多空格的格式问题
Formatting issue with too many spaces being returned in a SELECT Query
前几天我问了一个关于添加 return 两天后日期的新列的问题。我现在得到了我需要的结果,但是两个日期(原始日期和日期加 2)之间的间距是 returning 109 个字符,我一辈子都想不出如何 return 它之间只有几个空格。
原始 SELECT 语句的格式很好,但是我认为在 ,lastupdate + 2 之后是问题所在。
我尝试将相同的“||” '||" "e.lastupdate, e.lastupdate + 2" 之间的格式,但发生这种情况时查询无法 运行。它 return 是一个 "Invalid Number" 错误。
select p.id||' '||p.lastname||' '||p.firstname||' '|| e.lastupdate, e.lastupdate + 2
from table p, othertable e
where p.id = e.id
and hold = 8
and id in (
select id from othertable
where buildinginfo is null
)
order by id;
实际结果(在 Whosebug 上显示不正确,但 05-SEP-18 和 07-SEP-18 之间有 109 个空格):
000000000 Scott Michael 05-SEP-18 07-SEP-18
预期结果:
000000000 Scott Michael 05-SEP-18 07-SEP-18
解决了!最后在 "e.lastupdate +2" 周围加上括号,实际上 运行!
select p.id||' '||p.lastname||' '||p.firstname||' '|| e.lastupdate||' '||
(e.lastupdate + 2)
from table p, othertable e
where p.id = e.id
and hold = 8
and id in
( select id from othertable
where buildinginfo is null )
order by id;
前几天我问了一个关于添加 return 两天后日期的新列的问题。我现在得到了我需要的结果,但是两个日期(原始日期和日期加 2)之间的间距是 returning 109 个字符,我一辈子都想不出如何 return 它之间只有几个空格。
原始 SELECT 语句的格式很好,但是我认为在 ,lastupdate + 2 之后是问题所在。
我尝试将相同的“||” '||" "e.lastupdate, e.lastupdate + 2" 之间的格式,但发生这种情况时查询无法 运行。它 return 是一个 "Invalid Number" 错误。
select p.id||' '||p.lastname||' '||p.firstname||' '|| e.lastupdate, e.lastupdate + 2
from table p, othertable e
where p.id = e.id
and hold = 8
and id in (
select id from othertable
where buildinginfo is null
)
order by id;
实际结果(在 Whosebug 上显示不正确,但 05-SEP-18 和 07-SEP-18 之间有 109 个空格):
000000000 Scott Michael 05-SEP-18 07-SEP-18
预期结果:
000000000 Scott Michael 05-SEP-18 07-SEP-18
解决了!最后在 "e.lastupdate +2" 周围加上括号,实际上 运行!
select p.id||' '||p.lastname||' '||p.firstname||' '|| e.lastupdate||' '||
(e.lastupdate + 2)
from table p, othertable e
where p.id = e.id
and hold = 8
and id in
( select id from othertable
where buildinginfo is null )
order by id;