title: SQL Pivot "Incorrect syntax near the keyword 'PIVOT'."
body: <p>I am new at using Pivot in SQL and ran into some trouble.</p>
  
  <p>I constantly keep getting an error, when i try to embed a pivot table to my Select-query, and despite hours of reading several webpages I cant seem to figure it out.</p>
  
  <p>I am working on a dashboard-db, which will contain several pivot-tables (5) in the query, one for each Dashboard. is this possible?</p>
  
  <p><strong>The error I'm getting is :</strong></p>
  
  <blockquote>
    <p>Msg 156, Level 15, State 1, Line 38
    Incorrect syntax near the keyword 'PIVOT'.</p>
  </blockquote>
  
  <p>My query looks like this</p>
  
  <pre><code>SELECT 
      /* Query for dashboard 1 **/
      [ProjectUID] AS [Project UID],
      [ + 8 Regular selects not related to the pivot  ]
  
      /* Query for dashboard 2 **/
      [...]
  
          /* Query for dashboard 3 **/
      [...]
  
          /* Dashboard WOWs */
      (SELECT * FROM [PB_Customer])
      PIVOT
          (
              COUNT (MValue) 
              for MValue
                  in (
                  [Customer],
                  [MNeeds],
                  [Bousa],
                  [backbook]
                  )
          ) AS pvt_table_wow
  
      FROM    [Table 1], [Table 2], [Table 3] 
  
      WHERE   Table1.ProjectUID=.Table2PROJECTUID 
              AND Table2.[Ping] IS NOT NULL 
              AND Table2.[Bousa] NOT IN ('0')
              AND Table1.ProjectUID=Table3.PUID;
  </code></pre>
  
  <p>Can anybody help me?</p>