【发布时间】:2017-11-27 23:35:45
【问题描述】:
我不明白为什么,但是我对 TRIM 关键字的实现不是 TRIMming 空格...这是我尝试过的代码:
SQL>
SQL> select ltrim('WebService Access Time'||null),rtrim(min(response_time)),rtrim(max(response_time)),rtrim(avg(response_time)) from myuser.access_log where access_date between to_date('2017/11/20','yyyy/mm/dd:hh24:mi:ss') and to_date('2017/11/26','yyyy/mm/dd:hh24:mi:ss');
WebService Access Time,3 ,40914 ,35.8903038316018836644721402687804875597
SQL>
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select ltrim('WebService Access Time'||null),min(response_time),max(response_time),avg(response_time) from myuser.access_log where access_date between to_date('2017/11/20','yyyy/mm/dd:hh24:mi:ss') and to_date('2017/11/26','yyyy/mm/dd:hh24:mi:ss');
WebService Access Time, 3, 40914, 35.8903038
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select trim(both from 'WebService Access Time'||null),trim(both from min(response_time)),trim(both from max(response_time)),trim(both from avg(response_time)) from myuser.access_log where access_date between to_date('2017/11/20','yyyy/mm/dd:hh24:mi:ss') and to_date('2017/11/26','yyyy/mm/dd:hh24:mi:ss');
WebService Access Time,3 ,40914 ,35.8903038316018836644721402687804875597
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select trim(both ' ' from 'WebService Access Time'||null),trim(both ' ' from min(response_time)),trim(both ' ' from max(response_time)),trim(both ' ' from avg(response_time)) from myuser.access_log where access_date between to_date('2017/11/20','yyyy/mm/dd:hh24:mi:ss') and to_date('2017/11/26','yyyy/mm/dd:hh24:mi:ss');
WebService Access Time,3 ,40914 ,35.8903038316018836644721402687804875597
SQL>
SQL>
SQL>
SQL>
SQL> select '>'|| trim (' removing spaces at both ends ') ||'<' "Spaces Removed" from dual;
>removing spaces at both ends<
SQL> select '>'|| trim(' removing spaces at both ends ') ||'<' "Spaces Removed" from dual;
>removing spaces at both ends<
SQL>
SQL>
SQL>
SQL>
SQL>
SQL> select 'WebService Access Time'||null,trim(min(response_time)),trim(max(response_time)),trim(avg(response_time)) from myuser.access_log where access_date between to_date('2017/11/20','yyyy/mm/dd:hh24:mi:ss') and to_date('2017/11/26','yyyy/mm/dd:hh24:mi:ss');
WebService Access Time,3 ,40914 ,35.8903038316018836644721402687804875597
如您所见,我一直在使用不同教程中的示例,试图让它工作——但似乎没有任何工作......我没有收到任何 SQL 错误,所以我假设语法是对的,但很明显,我遗漏了一些东西!
请帮忙!
这项工作正在通过 SQLPlus 执行,没有可用的 GUI 客户端。
注意:假设我是非特权用户,只有 SELECT、UPDATE、INSERT 的 GRANTS。
【问题讨论】:
-
我不明白您报告的“不良行为”是什么。事实上,在 OUTPUT 中,
min(response_time)值似乎占用了太多空间(用您似乎无法删除的空间填充)?这是 SQL*Plus 的一个特性,而不是 SQL 问题!您需要使用 SQL*PlusCOLUMN命令格式化输出列。 -
鉴于您的问题完全是关于呈现查询的输出,您至少可以做的是格式化您的问题,以便您正在运行的查询及其输出是可读的。您希望我们花时间帮助您,但您不会花时间来提出问题。