title: PostgreSQL says "return and sql tuple descriptions are incompatible"
body: <p>I have the following data: </p>
  
  <pre><code>ID  CLASS   VALUE
  1   NHB    700905.7243
  1   HBW    164216.1311
  1   HBO    700905.7243
  2   NHB    146023.3792
  2   HBW    89543.2972
  2   HBO    82152.072
  3   NHB    1409818.328
  3   HBW    220430.7922
  3   HBO    323512.9391
  4   NHB    48711.3814
  4   HBW    163385.1575
  4   HBO    363352.3441
  </code></pre>
  
  <p>That I want to reorganize as: </p>
  
  <pre><code>ID     HBO             HBW              NHB
  1   700905.7243    164216.1311      700905.7243
  2   82152.072      89543.2972       146023.3792
  3   323512.9391    220430.7922      1409818.328
  4   363352.3441    163385.1575      48711.3814
  </code></pre>
  
  <p>Please note that the values in columns HBW, HBO and NHB are totals (sum). </p>
  
  <p>Here is the script I am using to create the output: </p>
  
  <pre><code>-- CREATE EXTENSION tablefunc;
  
  SELECT *
  FROM  CROSSTAB
  (
      'SELECT _tlfd.id,   
      _tlfd."class",
      _tlfd."value"
      FROM public._tlfd
      WHERE _tlfd."class" = ''HBW'' or _tlfd."class" = ''HBO'' or _tlfd."class" = ''NHB'' 
      ORDER BY 1,2'
  ) 
      AS
  (
      "class" int, 
      "HBW" text,
      "HBO" text,
      "NHB" text,
      --"Purpose" varchar, 
      "value" double precision
  );
  </code></pre>
  
  <p>When I run the script I get this error: </p>
  
  <blockquote>
  <pre><code>ERROR:  return and sql tuple descriptions are incompatible. 
  </code></pre>
  </blockquote>
  
  <p>I am not sure what this means and how to correct the error. Can someone please let me know:</p>
  
  <ol>
  <li>What am I doing wrong in the script?</li>
  <li>Will my script produce the desired output?</li>
  </ol>