Incorrect syntax near the keyword 'select' while execuing query

Posted by sam on Stack Overflow See other posts from Stack Overflow or by sam
Published on 2010-03-07T23:53:57Z Indexed on 2010/03/08 0:01 UTC
Read the original article Hit count: 224

Filed under:
|

I am getting Incorrect syntax near the keyword 'select' after executing the following code.

declare @c int

SELECT @c = COUNT(*) 
  FROM (select id, max(date_stored)
         from table B
   INNER JOIN table P ON B.id = P.id
        where id = 3)

select @c

I want to select total no of records having max stored dates in database. Can any one plz tell what I am doing wrong

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005