I am trying to use the below query in a stored procedure to get everything from Promotion table and count(*) from Merchant_Views table. But i get the error “Incorrect syntax near the keyword ‘from’.”. This is in SQl Server 2005. I am wonddering how this can be solved. What am i doing wrong. Thanks for all the help!
SELECT *, (count(*) from Merchant_Views) FROM dbo.Promotion
INNER JOIN dbo.Merchant_Location ON dbo.Promotion.LocationID = dbo.Merchant_Location.LocationID
INNER JOIN dbo.Merchant_Views MV ON MV.LocationID = dbo.Promotion.LocationID
and dbo.Merchant_Views.ClickDate >= dbo.Promotion.startDate
and dbo.Merchant_Views.ClickDate <= dbo.Promotion.expireDate
and dbo.Merchant_Views.Status <> 'printed'
WHERE dbo.Promotion.MerchantID=@MerchantID AND PostType=@PostType
Thank you!!
You are just missing a SELECT before COUNT(*)