I would like to Substring a the first 4 characters of a varchar2 field

Experts,

I'd like to create a new column in my database that consists of the first 4 characters of an existing varchar2 column.

The table looks like this
APPCNUM         COLUMN1
1                        12323455
2                         23465236
3                         24352345
4                         23453266
 
However, I'd like it to look like this:
APPCNUM         COLUMN1
1                        1232
2                         2346
3                         2435
4                         2345
danmcd0913Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sdstuberCommented:
select appcnum,substr(column1,1,4) column1 from your_table
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chakravarthi AyyalaDatabase AdministratorCommented:
Use this: substr(column1,1,4)
Please see below.
Hope this helps!
=========================================================
SQL> create table a(appcnum number, column1 varchar2(20));

Table created.

SQL> insert into a values(1,12323455);

1 row created.

SQL> create table b as select appcnum, substr(column1,1,4) column1 from a ;

Table created.

SQL> select * from a ;

   APPCNUM COLUMN1
---------- --------------------
         1 12323455

1 row selected.

SQL> select * from b ;

   APPCNUM COLUMN1
---------- ----------------
         1 1232

1 row selected.

SQL>
==================================================================
0
Chakravarthi AyyalaDatabase AdministratorCommented:
I created another table in my example.
Hope you can move forward based on the example given.
0
awking00Commented:
Are you looking for an update?
update table set column1 = substr(column1,1,4);
0
danmcd0913Author Commented:
Thanks for your time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.