开发者

Error in query sql server 2005

开发者 https://www.devze.com 2023-02-20 18:33 出处:网络
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 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

精彩评论

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