首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

oracle去字段后4位如何写

2012-01-26 
oracle去字段后4位怎么写啊表test字段id VARCHAR类型 想取它的后四位请问怎么写这条sql啊?[解决办法]SQL c

oracle去字段后4位怎么写啊
表test 字段id VARCHAR类型 想取它的后四位 请问怎么写这条sql啊?

[解决办法]

SQL code
select substr(id, 1,length(id)-4) as idfrom test;
[解决办法]
select substr(id,length(id)-4+1) as id
from test;
[解决办法]
select substr(c1,length(c1)-4+1) from t1
[解决办法]
SQL code
SQL> with tmp as (  2       select '12345' data from dual union all  3       select '1' data from dual union all  4       select '123' data from dual  5       )  6  select substr(data, -least(length(data), 4))  7    from tmp; SUBSTR(DATA,-LEAST(LENGTH(DATA------------------------------23451123 

热点排行