title: SQL Server and nested SELECT:  ...Incorrect syntax near ')'?
body: <p>I get this error when executing my code. What does this mean? I'm using SQL Server Management Server Express.</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 7</p>
    
    <p>Incorrect syntax near ')'.</p>
  </blockquote>
  
  <hr>
  
  <pre><code>declare @start datetime
  declare @end datetime
  set @start = '2012/01/02'
  set @end = '2012/01/06'
  
  
  SELECT  
   SUM(VCount) as [Total],
   vdate,
   (select COUNT(VIP) From (SELECT DISTINCT(VIP) FROM dbo.Visiter)) as [IP3]
  FROM dbo.Visiter 
  where VDate between @start and @end
  GROUP BY VDate 
  </code></pre>