Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Display data in dynamic columns

I have data like this in the postgres db column with two rows named Data_Column,

sample data data

I would like to display the data like this,The colon left hand side is the column name and the colon right hand side is the column value.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Output Format required

I have tried crosstab function ,but it is not working for me.Can u help on this.

>Solution :

This can be achieved using substring() with a regular expression:

select substring(data_column from 'data_as_of_date:([0-9]+)') as data_as_of_date,
       substring(data_column from 'unique_cc:([0-9]+)') as unique_cc
from the_table;       
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading