title: msg 102,level 15,state 1,line 9 Incorrect syntax near '('-
body: <p>I am working on a cross tab query in SQL Server 2008. Everything appear fine apart from this error I am getting.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>select * from 
      (select ITEM_CODE,NET_PRODUCTION_QUANTITY,RAW_MATERIAL_CODE,DATE_ID  from dbo.ODST_PRODUCTION_TRANS 
      ) n
      pivot
      (sum(NET_PRODUCTION_QUANTITY) for datename(month,DATE_ID) In ([January],[February],[March],[April],[May],[June])) as pvt
  where RAW_MATERIAL_CODE = 'X' and DATE_ID between '01-Jan-11' and '30-Jun-11'.
  </code></pre>
  
  <p>The problem is where the <code>datename(month,date_id)</code> but I can't figure it out. Can anyone give me a solution? </p>
  
  <p>Thanks in advance</p>