1

I have a following table.

name        | Keyword       | Value
------------------------------------------
John        | #nickname     | Chandler
John        | #phone        | **********
John        | #name         | John
Doe         | #nickname     | Ross
Doe         | #phone        | ##########
Doe         | #name         | Doe
Joey        | #phone        | !!!!!!!!!!
Joey        | #name         | Joey

I need to convert it to the following.

Name        | #nickname | #phone        | #name
--------------------------------------------------
John        | Chandler  | **********    | John
Doe         | Ross      | ##########    | Doe
Joey        | NULL      | !!!!!!!!!!    | Joey

Here, the values for the keyword in first table is not fixed. It can be any string.

What should be my query to perform this in PostgreSQL?

shashwat
  • 49
  • 1
  • 5
  • You can use `CROSSTAB` for that, here is [an example](https://stackoverflow.com/questions/3002499/postgresql-crosstab-query) – Thomas B Nov 20 '19 at 20:26

0 Answers0