title: postgres crosstab, ERROR: The provided SQL must return 3 columns
body: <p>Hello I have created a view, but want to pivot it.</p>
  
  <p>OUTPUT before pivoting:</p>
  
  <pre><code>   tag1  |  qmonth1  |  qmonth2  |  sum1
   --------+-----------+-----------+--------
   name1   |  18-05   |  MAY      |  -166
   name2   |  18-05   |  MAY      |  -86
   name3   |  18-05   |  MAY      |  35
   name1   |  18-06   |  JUN      |  -102
   name2   |  18-06   |  JUN      |  -32
   name3   |  18-06   |  JUN      |  -75
   name1   |  18-09   |  AVG      |  -135
   name2   |  18-09   |  AVG      |  -52
   name3   |  18-09   |  AVG      |  -17
  </code></pre>
  
  <p>expected output:</p>
  
  <pre><code> qmonth2 | name1 | name2 | name3
   --------+-------+-------+-------
    MAY    | -166  | -86  |  35
    JUN    | -102  | -32  | -75
    AVG    | -135  | -52  | -17
  </code></pre>
  
  <p>my full query:</p>
  
  <pre><code>SELECT tag1,qmonth2,sum1 FROM crosstab 
  ('SELECT tag1::text,qmonth1,qmonth2::text,sum1::numeric 
  FROM public."chartdata_chart3"') 
  AS ct ( "tag1" TEXT,"qmonth2" TEXT,"sum1" NUMERIC);
  </code></pre>
  
  <p>I getting this error and unable to resolve:</p>
  
  <pre><code>ERROR:  invalid source data SQL statement
  DETAIL:  The provided SQL must return 3 columns: rowid, category, and values.
  SQL state: 22023
  </code></pre>