I am trying to learn JOINS but I can't get this one to work. Trying to join a second table to the first one to get the name of the division, the dname variable.
select e.COUNT(empID), e.SUM(salary), e.DID, d.dname
from employee e
right join division on e.DID=d.DID
group by DID
CodePudding user response:
select COUNT(e.empID), SUM(e.salary), e.DID, d.dname
from employee e
right join division d on e.DID=d.DID
group by e.DID, d.dname
CodePudding user response:
You missed the alias d
on division
and on the Group, and the alias goes inside the function call on the select line
select COUNT(e.empID), SUM(e.salary), e.DID, d.dname
from employee e
right join division d on e.DID=d.DID
group by e.DID