2

I have a column and I would like to get a new column using only the first two characters. I would have assumed the following should work, but it throws FROM keyword not found where expected error

SELECT *,
       SUBSTR(PHONE_NUMBER , 1,2) AS MY_PHONE_NUMBER
FROM PHONE_NOS;

Try it here

1 Answer 1

2

Alias the table and use it in the statement:

SELECT p.*,
       SUBSTR(p.PHONE_NUMBER, 1, 2) AS MY_PHONE_NUMBER
FROM PHONE_NOS p;
Sign up to request clarification or add additional context in comments.

1 Comment

rookie mistake... thanks! Leaving the post online, since it does not appear to be a duplicate and possibly others look for the same information

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.