我有一张这样的表
ID COACODE
-------------------
1 10200001
我希望select语句将其拆分为
ID BR DEPT MINS
-------------------
1 10 2000 01
答案 0 :(得分:1)
SUBSTRING函数允许您从字符串中提取子字符串。
注意:它适用于每行具有相同长度的值,否则会产生错误
SELECT ID,SUBSTRING(COACODE, 1, 2) as BR , SUBSTRING(COACODE, 3, 6) as DEPT , SUBSTRING(COACODE, 7, 8) as MINS from table_name