简体   繁体   English

SELECT查询中返回太多空格的格式问题

[英]Formatting issue with too many spaces being returned in a SELECT Query

I asked a previous question the other day about adding a new column that returns a date two days after. 前几天,我问了一个先前的问题,关于添加一个新列,该列返回两天后的日期。 I am now getting the results I need, however the spacing between the two dates (the original and the date plus 2) is returning 109 characters and I can't for the life of me figure out how to return it with only a few spaces between. 我现在正在获取所需的结果,但是两个日期(原始日期和日期加2)之间的间距返回109个字符,我一生无法弄清楚如何仅用几个空格返回它之间。

The format of the original SELECT statement is fine, however after the ,lastupdate + 2 is where the issue lays I believe. 原始SELECT语句的格式很好,但是,我相信问题是在lastlast + 2之后。

I've attempted to put the same "||' 我试图将相同的“ ||” '||" '||“ format between the "e.lastupdate, e.lastupdate + 2", but the query fails to run when this happens. 格式介于“ e.lastupdate,e.lastupdate + 2”之间,但是在这种情况下查询将无法运行。 It returns an "Invalid Number" error. 它返回“无效号码”错误。

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;

Actual Results (Not showing correct on StackOverflow, but there's 109 spaces between 05-SEP-18 and 07-SEP-18): 实际结果(在StackOverflow上显示不正确,但是05-SEP-18和07-SEP-18之间有109个空格):

000000000    Scott    Michael    05-SEP-18                                                                                                         07-SEP-18

Expected Results: 预期成绩:

000000000    Scott    Michael    05-SEP-18    07-SEP-18

Solved it! 解决了! Ended up putting a parenthesis around the "e.lastupdate +2" and it actually ran! 最终在“ 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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM