开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜