Error in query sql server 2005
i am getting an error in this Query
lik开发者_Go百科e this
select list because it is not contained in either an aggregate function or the GROUP BY clause
i have declared the parameters to
DECLARE
@Cnt1 INT,
EmpName varchar(50)
SELECT @Cnt1 =COUNT(EmpID),@EmpName=Employeefirstname FROM Employee WHERE EmpID='12'
pls let me know how can i solve this issue.
Thanks Prince
Every field in the SELECT
clause must be an aggregated value or be contained in a GROUP BY
clause. So the fix would be:
SELECT @Cnt1 =COUNT(EmpID),@EmpName=Employeefirstname FROM Employee
WHERE EmpID='12' GROUP BY Employeefirstname
精彩评论