title: SQL - How to transpose?
body: <p>I have something similar to the following table:</p>
  
  <pre><code>================================================
  | Id | UserId | FieldName     | FieldValue     |
  =====+========+===============+================|
  | 1  | 100    | Username      | John Doe       |
  |----+--------+---------------+----------------|
  | 2  | 100    | Password      | pass123!       |
  |----+--------+---------------+----------------|
  | 3  | 102    | Username      | Jane           |
  |----+--------+---------------+----------------|
  | 4  | 102    | Password      | $ecret         |
  |----+--------+---------------+----------------|
  | 5  | 102    | Email Address | jane@email.com |
  ------------------------------------------------
  </code></pre>
  
  <p>I need a query that will give me a result like this:</p>
  
  <pre><code>==================================================
  | UserId | Username  | Password | Email Address  |
  =========+===========+===========================|
  | 100    | John Doe  | pass123! |                |
  |--------+-----------+----------+----------------|
  | 102    | Jane      | $ecret   | jane@email.com |
  |--------+-----------+----------+----------------|
  </code></pre>
  
  <p>Note that the values in FieldName are not limited to Username, Password, and Email Address. They can be anything as they are user defined.</p>
  
  <p>Is there a way to do this in SQL?</p>