When I use following query it works:
select d.id,
d.name,
count(e.id) as numberofemployees
from department d,
employee1 e
where d.id=e.deptid
group by d.id,
d.name
order by d.id;
But when I use following query it gives me error:
select d.id,
d.name,
count(e.id) as numberofemployees
from department d,
employee1 e
where d.id=e.deptid
group by d.id
order by d.id;
Error is as follows:
select d.id, d.name, count(e.id) as numberofemployees
ERROR at line 1: ORA-00979: not a GROUP BY expression
I don't understand what the problem is. I think grouping on single column should be fine. Any help will be appreciated.