title: Transforming row data into columns in SQL Server
body: <p>I have table with the data in following format.</p>
  
  <pre><code>User ID| Date Paid  | Amount Paid
  - - - - - - - - - - - - - - - - - 
  1      | 2019-04-01 | 120
  1      | 2019-03-01 | 120
  1      | 2019-05-01 | 130
  2      | 2019-03-01 | 100
  2      | 2019-04-01 | 110
  3      | 2019-05-01 | 100
  </code></pre>
  
  <p>I need export this table into a format where all of the records for a single user should be in a single row, and date paid and amount records should start from left with the oldest record first.</p>
  
  <pre><code>User ID | 1st Date Paid | 1st Amount Paid | 2nd Date Paid | 2nd Amount Paid | 3rd Date Paid | 3rd Amount Paid | . . . . . 
  - - - - - - - -  - - - - - -  - - - -- - - - - - --  -- - -  -- - - - - - - - 
     1    | 2019-03-01    | 120             | 2019-04-01    | 120             | 2019-05-01 | 130
     2    | 2019-03-01    | 100             | 2019-40-01    | 110             |
     3    | 2019-05-01    | 100             |
  </code></pre>
  
  <p>There could be up to a maximum of 10 records per user, so the export should contain the date paid and amount paid columns 10 times. If a user doesn't contain 10 records, then those columns will be left empty.</p>
  
  <p>What is the best way to achieve this result?</p>