表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