0

I have a table called event. which is like :

user_id    feature_name  feature_value
   1          launced         yes
   1          voice_enabled   no
   1          trim_used       yes
   1          voice_enabled   yes
   1          trim_used       yes  
   2          launched         yes
   2          voice_enabled   no
   2          trim_used       no
   2          voice_enabled   yes
   2          zoom_used       yes 

There are thousand of rows like this and In feature_name column there can more features be added if any users would use it.

I have to convert this table in more meaningful format where each feature_name will be a separate column and having the count of the feature used by a particular user.

So output table looks like:

user_id   launched  voice_enabled  trim_used  zoom_used
   1         1           1             2         0
   2         1           1             0         1

Any help would be much appreciated. I am using PostgreSQL.

Rajeev kumar
  • 163
  • 1
  • 15

1 Answers1

-1

You can very well use transpose for your use case.

Please see post below which explains it:

Postgres - Transpose Rows to Columns

Community
  • 1
  • 1
shankarsh15
  • 1,947
  • 1
  • 11
  • 16