title: Pivot duplicate column names and get all values for columns
body: <p><strong>EXPLAINATION</strong></p>
  
  <p>Imagine that I have 2 tables. <code>FormFields</code> where are stored column names as values, which should be pivoted and second table <code>FilledValues</code> with user's filled values with <code>FormFieldId</code> provided.</p>
  
  <p><strong>PROBLEM</strong></p>
  
  <p>As you see (below in <em>SAMPLE section</em>) in <code>FormFields</code> table I have duplicate names, but different ID's. I need to make that after joining tables, all values from <code>FilledValues</code> table will be assiged to column names, not to Id's. </p>
  
  <p>What I need better you will see in <em>OUTPUT</em> section below.</p>
  
  <p><strong>SAMPLE DATA</strong></p>
  
  <p><code>FormFields</code></p>
  
  <pre><code>ID   Name  GroupId
  1    col1     1
  2    col2     1
  3    col3     1
  4    col1     2
  5    col2     2
  6    col3     2
  </code></pre>
  
  <p><code>FilledValues</code></p>
  
  <pre><code>ID  Name  FormFieldId  GroupID
  1     a       2           1
  2     b       3           1
  3     c       1           1
  4     d       4           2
  5     e       6           2
  6     f       5           2
  </code></pre>
  
  <p><strong>OUTPUT FOR NOW</strong></p>
  
  <pre><code>col1    col2    col3
   c       a        b  -- As you see It returning only values for FormFieldId 1 2 3
                       -- d, e, f are lost that because It have duplicate col names, but different id's
  </code></pre>
  
  <p><strong>DESIRED OUTPUT</strong></p>
  
  <pre><code>col1    col2    col3
   c       a        b
   e       f        d 
  </code></pre>
  
  <p><strong>QUERY</strong></p>
  
  <pre><code>SELECT * FROM 
  (
      SELECT  FF.Name  AS NamePiv, 
              FV.Name  AS Val1     
      FROM FormFields FF
      JOIN FilledValues FV ON FF.Id = FV.FormFieldId      
  ) x
  PIVOT
  (
      MIN(Val1)
      FOR NamePiv IN ([col1],[col2],[col3])
  ) piv
  </code></pre>
  
  <p><strong><a href="http://sqlfiddle.com/#!3/164e0/1" rel="nofollow">SQL FIDDLE</a></strong></p>
  
  <p>How can I produce the OUTPUT with the multiple rows?</p>