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.