How to convert dynamic table rows to columns in postgresql

64 Views Asked by At

I want to convert the below table into my expected output format. Here the input is dynamic. But my code should be generic to handle dynamic input tables

Input 1:

key Value
Id 1
Name AAAA
Id 2
Name BBBB

Output 1:

Id Name
1 AAAA
2 BBBB

Input 2:

key Value
Id 1
Name AAAA
Dept IT
Id 2
Name BBBB
Dept Admin

Output 2:

Id Name Dept
1 AAAA IT
2 BBBB Admin

Not able to find any results

0

There are 0 best solutions below