title: Transpose some columns based on condition in another two columns in sql
body: <p>I am new in SQL and please forgive for that. I have a scenario where I should use SQL to get the result - </p>
  
  <p>I have a table as given below.</p>
  
  <pre><code>User    System  Roles
   U1      S1      R1
   U1      S1      R2
   U1      S2      R1
   U2      S1      R1
   U3      S2      R1
   U3      S2      R2
   U3      S2      R3
  </code></pre>
  
  <p>I need to use SQL and get the result as given below.</p>
  
  <pre><code>User    System  Role1   Role2   Role3
   U1      S1      R1      R2 
   U1      S2      R1     
   U2      S1      R1     
   U3      S2      R1      R2       R3
  </code></pre>
  
  <p>The issue here is that the User Count, System Count and Role count is not constant - it can vary each time.</p>
  
  <p>I tried to do it with my little SQL knowledge, but could not achieve this. If someone can help with this, that would be very helpful.</p>
  
  <p>Thanks,
  Hari</p>