当前位置: 代码迷 >> Oracle管理 >> select length(to_char(24,'00')) from dual 值如何为3?
  详细解决方案

select length(to_char(24,'00')) from dual 值如何为3?

热度:528   发布时间:2016-04-24 05:33:16.0
select length(to_char(24,'00')) from dual 值怎么为3??
select length(to_char(24,'00')) from dual 值怎么为3??

应该是2把

------解决方案--------------------
Because the resulf of follwing sql is ' 24':
select to_char(24,'00') from dual;

You can use another method:
select lengthb(to_char(24)) from dual;
------解决方案--------------------
http://www.itpub.net/thread-404943-1-1.html 可以参考这个

然后看看这四个的结果
SQL code
select length(trim(to_char(24,'00'))) from dual select length(to_char(24,'00')) from dual select to_char(24,'00') from dualselect to_char(24,'fm00') from dual
------解决方案--------------------
探讨

Because the resulf of follwing sql is ' 24':
select to_char(24,'00') from dual;

You can use another method:
select lengthb(to_char(24)) from dual;

------解决方案--------------------
可以试着多举几个例子 看看各自的效果有什么不同 既然显示是3 肯定有道理咯
------解决方案--------------------
SQL code
select length(to_char(-24,'00')) from dual  --3select to_char(-24,'00') from dual -- '-24'--也是3,难道是隐藏符号位?
------解决方案--------------------
探讨
Because the resulf of follwing sql is ' 24':
select to_char(24,'00') from dual;

You can use another method:
select lengthb(to_char(24)) from dual;

------解决方案--------------------
-- 是的,前面有个空格(如果是负数,空格就变量成减号,主要是to_char()函数格式化的问题引起滴。
-- 例如:select to_char(-24,'00') from dual;则显示为:
-24

-- 估计这个空格是预留的符号位。

  相关解决方案