right join leaving one row from right table
You are grouping by the thing you are counting, not by the department name. 
Change your group by to:
group by b.deptname

Edit:Adding a little flavor text as requested.

Basically what is happening is you are choosing to aggregate one of the values (in this case the counts of the salary) so that it "rolls up", and the group by generally indicates which value you want to do the rolling up by. 

It makes some sense to say "I want to group by the number of employees" but you are actually trying to express "I want to return the number of employees grouped by department."