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

How to concatenate two columns wrt a Key in PostgreSQL

I have a table with two keys Call_ID and UUID with their respective Intent and Products. I need to concatenate the two columns with respect to UUID , such that for each UUID their would be unique intent_prouct pairs. The input and output table is given in the image

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

>Solution :

You can do that using aggregations. ie:

with basedata as (
select Call_Id, UUID, max(Intent) as Intent, Max(Product) as Product
    from myTable
    group by Call_Id, UUID
)
select Call_Id, UUID, Intent || ' ' || Product as Intent_Product
from basedata;
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