title: Unpivot and pivot with in SQL Server table
body: <p>I'm looking for some guidance (new to SQL Server in my college work) with unpivot and pivoting data in the following format</p>
  <p>Source table:</p>
  <pre class="lang-none prettyprint-override"><code>JobNumber   SourceRowInsertDate Column3 Column5 Column6 Column7 Column8 Column9 Column10    Column11    Column12    Column13    Column14
  1832801 9/21/2021   MonthYear   21-Mar  21-Apr  21-May  21-Jun  21-Jul  21-Aug  21-Sep  21-Oct  21-Nov  21-Dec
  1832801 9/21/2021   CONDUIT 10  25  40  55  70  85  100 115 130 145
  1832801 9/21/2021   WIRE    20  35  50  65  80  95  110 125 140 155
  1832801 9/21/2021   SW GEAR 35,000  68  -34,864 -69,796 -104,728    -139,660    -174,592    -209,524    -244,456    -279,388
  1832801 9/21/2021   GENERATOR   30  254 478 702 926 1150    1374    1598    1822    2046
  </code></pre>
  <p>Output:</p>
  <pre class="lang-none prettyprint-override"><code>JobNumber   SourceRowInsertDate MonthYear   CONDUIT WIRE    SW GEAR GENERATOR
  1832801 9/21/2021   21-Mar  10  20  35,000  30
  1832801 9/21/2021   21-Apr  25  35  68  254
  1832801 9/21/2021   21-May  40  50  -34,864 478
  1832801 9/21/2021   21-Jun  55  65  -69,796 702
  1832801 9/21/2021   21-Jul  70  80  -104,728    926
  1832801 9/21/2021   21-Aug  85  95  -139,660    1150
  1832801 9/21/2021   21-Sep  100 110 -174,592    1374
  1832801 9/21/2021   21-Oct  115 125 -209,524    1598
  1832801 9/21/2021   21-Nov  130 140 -244,456    1822
  1832801 9/21/2021   21-Dec  145 155 -279,388    2046
  </code></pre>
  <p>I tried the following SQL , but it is not giving the desired output,</p>
  <pre class="lang-sql prettyprint-override"><code>;WITH CTE_Material AS (
   SELECT 
    JobNumber
       ,RowInsertDate AS SourceRowInsertDate
       ,Column3   ,Column5    ,Column6    ,Column7    ,Column8    ,Column9    ,Column10   ,Column11   ,Column12   ,Column13   ,Column14   
  FROM [dbo].RawInput
  
  )
  SELECT * FROM CTE_MATERIAL
   UNPIVOT
   (
      MonthYear
      FOR values_ IN (  Column3   ,Column5    ,Column6    ,Column7    ,Column8    ,Column9    ,Column10   ,Column11   ,Column12   ,Column13   ,Column14   )
   ) AS DataUnpivot
  </code></pre>
  <p>Appreciate the help!</p>
  <p>DDL:</p>
  <pre class="lang-sql prettyprint-override"><code>create table  dbo.RawInput
  (
  JobNumber varchar(255) null,    
  SourceRowInsertDate varchar(255) null,  
  Column3 varchar(255) null,  
  Column5   varchar(255) null,    
  Column6   varchar(255) null,    
  Column7   varchar(255) null,    
  Column8   varchar(255) null,    
  Column9   varchar(255) null,    
  Column10  varchar(255) null,    
  Column11  varchar(255) null,    
  Column12  varchar(255) null,    
  Column13  varchar(255) null,    
  Column14  varchar(255) null 
  
  )
  
  
  insert into dbo.RawInput (JobNumber,    SourceRowInsertDate ,Column3    ,Column5    ,Column6    ,Column7    ,Column8    ,Column9    ,Column10   ,Column11   ,Column12   ,Column13   ,Column14)
  values
  ('1832801','9/1/2021','MonthYear','21-Mar','21-Apr','21-May','21-Jun','21-Jul','21-Aug','21-Sep','21-Oct','21-Nov','21-Dec')
  ,('1832801','9/1/2021','CONDUIT','10','35','40','55','70','44429','100','115','130','145')
  ,('1832801','9/1/2021','WIRE','20','68','50','65','80','85','110','125','140','155')
  ,('1832801','9/1/2021','SW GEAR','35000','254','-34864','-69796','-104728','95','-174592','-209524','-244456','-279388')
  ,('1832801','9/1/2021','GENERATOR','30','','478','702','926','-139660','1374','1598','1822','2046')
  </code></pre>