我想从用substr从-001.00里面取到-1这个值,想请问下该怎么取。
解决方案 »
- ORACLE SQL语句求助 oracle中table中默认存在emp,dept表,在这基础上询问
- 关于ORACLE跟踪用户操作
- 存储过程中的for循环的条件可以这样写吗?
- 如何执行带有输出参数的存储过程
- PLSQL Developer 开发工具,可以用来开发sql server数据库么?请问怎么连接呢?谢谢
- 请教,下面的sql 如何写
- .net 中怎样能把oracle数据进行整库导出?
- 速度问题?关于三个数据库
- 求大神解答!Oracle_12c中没有scott用户,运行了RDBMS\ADMIN里的scott.sql脚本之后好像没效果啊
- PHP和oracle数据库连接后,用户名和密码无效是咋回事?能正常登录sql\PLUS呀
- 求SQL语句,多表连接更新的问题
- oracle的imp问题。
SQL> select substr(replace('-001.00','0',''),1,2) from dual;
SUBSTR(REPLACE('-001.00'
------------------------
-1
SQL> select trunc(-001.00,0)+10 from dual;
TRUNC(-001.00,0)+10
-------------------
9
SQL> select substr(replace('-001.00','0',''),1,2)+10 sum from dual;
SUM
----------
9
SQL> select trunc(-001.00) from dual;
TRUNC(-001.00)
--------------
-1
oracle trunc for number
The first position in the string is always 1.
length is optional. It is the number of characters to extract.
If this parameter is omitted, substr will return the entire string.
Note:If start_position is 0, then substr treats start_position as 1
(ie: the first position in the string).If start_position is a positive number, then substr starts from the beginning of the string.
If start_position is a negative number, then substr starts from the end of the string and
counts backwards.
If length is a negative number, then substr will return a NULL value.Applies To:Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11gFor example:substr('This is a test', 6, 2) would return 'is'
substr('This is a test', 6) would return 'is a test'
substr('TechOnTheNet', 1, 4) would return 'Tech'
substr('TechOnTheNet', -3, 3) would return 'Net'
substr('TechOnTheNet', -6, 3) would return 'The'
substr('TechOnTheNet', -8, 2) would return 'On'