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