The console or server log should give you some idea about what is wrong, the stacktrace is always available. I have doubts about the 'ID' attribute. I don't think it's available in oql.
The OQL in Crash Course, please try this:
SELECT D/Name DepartmentName, COUNT(S/id) Number FROM UserManager.Shift S JOIN S/UserManager.Shift_PlanningPeriod/UserManager.PlanningPeriod/UserManager.PlanningPeriod_Department/UserManager.Department D LEFT OUTER JOIN S/UserManager.Shift_Employee/UserManager.Employee E WHERE E/ID = NULL GROUP BY D/Name