SQl Not a group by expression, what am I missing?

Viewed 24

I'm learning Oracle SQL right now and I'm stuck on this problem that keeps saying "Not a group by expression". What am I missing here that is preventing this from working properly?

select e.empid as "ID", e.name as "Employee Name", count(w.pid) as "Total Projects", sum(w.hours) as "Total Hours"
from employee e inner join workon w on e.empid=w.empid
group by e.empid
having e.did = (select did from division where lower(dname) = lower('marketing'))
1 Answers

when you use an aggregate function you will have to provide the column on which aggregation has to be performed.

here you either have to remove e.name or include e.name in the group by clause.

Related