title: postgresql pivot with multiple columns having data
body: <p>i want to pivot/crosstab below table</p>
  <p><a href="https://i.stack.imgur.com/wAb55.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wAb55.png" alt="source data" /></a></p>
  <p>I tried below query in postgresql but it gives error ERROR:  invalid return type
  DETAIL:  Query-specified return tuple has 6 columns but crosstab returns 5</p>
  <pre><code> SELECT * FROM crosstab(
  'select Key,status,v_text,v_number,v_dob from table 
      where type = ''First_Name'' or type = ''Last_Name''  or type = ''DOB'' or type = ''Contact'' order by 1',
  'select distinct type  from table where type = ''First_Name'' or type = ''Last_Name'' or type = ''DOB'' or type = ''Contact'' order by 1')
   AS ct( Key int, First_Name text,   Last_Name  text, DOB date, Contact int);
  </code></pre>
  <p>required output is like below which has all types with values. Is it possible in pgsql</p>
  <p><a href="https://i.stack.imgur.com/hH1yO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hH1yO.png" alt="enter image description here" /></a></p>