Hi all, I’m following the new crash course and am getting an error in the provided OQL query. The query is provided in lecture 10.2.3: 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 GROUP BY D.Name HAVING E/ID = NULL The error is: invalid HAVING expression. The idea is to find unused shifts per department, where there is no employee assigned (hence, HAVING E/ID = NULL). I have some SQL experience, but I can’t find what is wrong here. Anyone have an idea?
E/ID isn't a column you've grouped by, so it can't appear in a having clause. You can solve it by adding E/ID to your grouped by attributes like this:
GROUP BY D.Name, E/ID
HAVING E/ID = NULL
Awesome, thanks! Sometimes you get stuck on the simplest of things :)