Accessing specific portions/values in a Column

All we need is an easy explanation of the problem, so here it is.

Experts,

I have this table in PG – I need to convert my output to the green part. Accessing specific portions/values in a Column

So in short extract certain parts and make them a different column. I can easily do this in Python but kind of stuck on Postgres.

Thanks,

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Looks like a simple string operation:

select manufacturer,
       address,
       contact, 
       left(contact::text, 3) as result_1, 
       right(contact::text, 3) as result_2
from the_table;

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply