这句话中的错误是什么 [英] what is mistake int this statement
本文介绍了这句话中的错误是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
选择 c。*,COUNT(p.empid)来自 empcdetails c inner join emppdetails p on p.empid = c.empid 其中 empstatus = ' 项目' group by p.empid order 按 MAX(c.empdoj) asc
解决方案
c。*
是问题所在。当您使用分组依据子句时,您只需在选择列表中提及分组中的特定列名称。
尝试相反。
选择 p.empid,COUNT(p.empid)
from empcdetails c
inner join emppdetails p
on p.empid = c.empid
其中 empstatus = ' project'
group by p.empid
order by MAX(c.empdoj) asc
尝试此子查询版本,如果你想拥有所有专栏
选择 c。*,A.myCount
来自 empcdetails c
加入
(
选择 p.empid,COUNT(p.empid) as myCount
来自 empcdetails cc
内部 join emppdetails p
on p.empid = cc.empid
group by p.empid
)A
A.empid = c.empid
其中 empstatus = ' 项目
订单 按 MAX(c.empdoj)< span class =code-keyword> asc
希望这会对你有所帮助。
select c.*,COUNT(p.empid) from empcdetails c inner join emppdetails p on p.empid=c.empid where empstatus ='project' group by p.empid order by MAX(c.empdoj)asc
解决方案
c.*
is the problem here. As you are using Group By clause, you have to mention only specific column names in your select list that are in group by.
Try this instead.
select p.empid,COUNT(p.empid) from empcdetails c inner join emppdetails p on p.empid=c.empid where empstatus = 'project' group by p.empid order by MAX(c.empdoj)asc
Try this subquery version, if you want to have all columns
select c.* , A.myCount from empcdetails c join ( select p.empid,COUNT(p.empid) as myCount from empcdetails cc inner join emppdetails p on p.empid = cc.empid group by p.empid ) A on A.empid = c.empid where empstatus = 'project' order by MAX(c.empdoj)asc
Hope this helps you.
这篇关于这句话中的错误是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文