title: DB2 SQL columns to rows
body: <p>I am trying to convert columns into rows like the example below.</p>
  
  <pre><code> _________________________________     ROW       | Columns  | values_
        |Column1 | Column2  | Column3   _____________________________
   _________________________________     1         | 1        | 12 
   Row 1|     12  |     25  |     11     1         | 2        | 25
   Row 2|     30  |      5  |     15 --&gt; 1         | 3        | 11
                                         2         | 1        | 30
                                         2         | 2        | 5
                                         2         | 3        | 15
  </code></pre>
  
  <p>For solving this i used following Statement</p>
  
  <pre><code>with t as (
        &lt;my query which builds the cross tab&gt;
       )
  select t.Row,
         (case when n.n = 1 then Column1
               when n.n = 2 then Column2
               when n.n = 3 then Column3
          end) as values_
  from t cross join
       (select 1 as n from sysibm.sysdummy1 union all
        select 2 from sysibm.sysdummy1 union all
        select 3 from sysibm.sysdummy1
       ) n; 
  </code></pre>
  
  <p>but I got the following Error</p>
  
  <blockquote>
    <p>THE STATEMENT CANNOT BE EXECUTED BY DB2 OR IN THE ACCELERATOR (REASON
    7). SQLCODE=-4742, SQLSTATE=560D5, DRIVER=4.19.56</p>
  </blockquote>
  
  <p>Has someone any hints to solve this? thanks</p>