How to merge and transform data in Postgres
0
votes
1
answer
218
views
A sql query yields data that looks like this:
| name | quality | magnitude |
| ----------- | ----------- | ----------- |
| john | kindness | 7
| john | greed | 2
| jane | kindess| 3 |
| jane | greed | 7 |
| john | temper | 9 |
| jane | temper | 4 |
I am wondering if there is a way to transform it into data that looks like this using SQL:
| name | personality |
| ----------- | ----------- | ----------- |
| john | kindess:7, greed:2, temper:9 |
| jane | kindess: 3, greed: 7, temper: 4 |
If yes:
1. How do it do it?
2. Is this an optimal/good idea?
I am on Postgres 9+
Asked by ritratt
(105 rep)
Sep 28, 2022, 08:00 PM
Last activity: Sep 29, 2022, 07:01 AM
Last activity: Sep 29, 2022, 07:01 AM