title: How can I Pivot this Rows
body: <p>My basic query </p>
  
  <pre><code> ID           Days      Y   Type
  3014    L;M;M;J;V;S;D   15  PDC
  3014    L;M;M;J;V;S;D   16  PDC
  3014    NULL            17  PDC
  3014    NULL            18  PDC
  3014    NULL            19  PDC
  3014    NULL            20  Altern
  3014    NULL            21  Altern
  </code></pre>
  
  <p>What i'm trying to achieve </p>
  
  <pre><code>3014 L;M;M;J;V;S;D L;M;M;J;V;S;D NULL NULL NULL NULL 15 16 17 
  </code></pre>
  
  <p>My Sql </p>
  
  <pre><code>    select * from (select 
      FS.FieldStudyId,
      C.Day as Dayss,
      C.IDCourse,
      C.Type
  from 
      FieldStudy FS,
      Course C  
  where 
      Fs.FieldStudyId = C.FieldStudyId)d
  pivot
  (
    max(Dayss)
    for FieldStudyId in (select z.FieldStudyId from FieldStudy z) 
  )x; 
  </code></pre>
  
  <p>But I doesn't work </p>
  
  <pre><code>Msg 156, Level 15, State 1, Line 14 Incorrect syntax near the keyword 'select'.
  Msg 102, Level 15, State 1, Line 14 Incorrect syntax near ')'
  </code></pre>