0

I have a table like this

ID   COACODE
-------------------
1    10200001

I want select statement split it like

ID   BR  DEPT  MINS
-------------------
1    10  2000  01  
ghalib
  • 203
  • 1
  • 2
  • 9

1 Answers1

1

use SUBSTRING()

The SUBSTRING functions allows you to extract a substring from a string.

NOTE: its works on when each row have same length of value otherwise it makes error

SELECT ID,SUBSTRING(COACODE, 1, 2) as BR , SUBSTRING(COACODE, 3, 6) as DEPT , SUBSTRING(COACODE, 7, 8) as MINS from table_name
JYoThI
  • 11,977
  • 1
  • 11
  • 26