sql - I want to create a query so each project number, name, number of assigned employees, and total assigned hours are diplayed -


i have code far, can't seem number of employees on eac porject.

select  p.projno, p.pname, count(e.ename) "num_assgd_emps", sum(a.num_hours) "num_hours"    emp e, assignment a, proj p e.empno = a.empno , p.projno = a.projno group e.ename, p.projno, p.pname; 

your group doesn't match aggregates. group should contain fields don't have aggregates sum/count. projno , pname in case. ename shouldn't in group by/ after all, if group that, count of 1!

so try

select  p.projno, p.pname, count(e.ename) "num_assgd_emps", sum(a.num_hours) "num_hours"    emp e, assignment a, proj p e.empno = a.empno , p.projno = a.projno group p.projno, p.pname; 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -