这个select语句有问题吗?
SELECT SUBSTR(FIELD_A,10,3) as MOVID,
MAX(LPAD((CAST(SUBSTR(FIELD_A,-3,3) as INT) + 1 ), 3, 0)) as NEXTMOVID
FROM ...
该字段为VARCHAR2
。
我想保留3个字符(这是数字)并添加1并与另一个varchar2连接
FIELD_A
MAX
想知道是否有更好的方法吗?
答案 0 :(得分:1)
据我了解,您需要关注:
SELECT SUBSTR(FIELD_A,10,3) as MOVID,
to_char(to_number(SUBSTR(FIELD_A, -3, 3)) + 1), '000') as NEXTMOVID
FROM ...