+ Reply to Thread
Results 1 to 3 of 3

Thread: Incorrect syntax near ')'

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    41

    Incorrect syntax near ')'

    I always get that error :
    Code:
    Incorrect syntax near ')'.
    i try to execute the below code :
    Code:
    declare @start datetime
    declare @end datetime
    set @start = '2012/11/08'
    set @end = '2012/12/12'
    
    SELECT  
     SUM(VCount) as [Total],
     vdate,
     (select COUNT(VIP) From (SELECT DISTINCT(VIP) FROM dbo.Visiter)) as [IP3]
    FROM dbo.Visitor 
    where VDate between @start and @end
    GROUP BY VDate

  2. #2
    you must provide an alias to the derived table , as you are using a derived table (a subquery) in the FROM clause
    so the code should be like that :
    Code:
    SELECT  
     SUM(VCount) as [Total],
     vdate,
     -- this is the alias
     (select COUNT(VIP) From (SELECT DISTINCT(VIP) FROM dbo.Visitor) AS a) as [IP3]
    FROM dbo.Visitor 
    where VDate between @start and @end
    GROUP BY VDate

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    41
    Thanks a lot lilian for your help.

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts