[Exam Preparation] Problem 5

[Exam Preparation] Problem 5

torosov avatar torosov -4 Точки

[Exam Preparation] Problem 5

Не мога да разбера защо това решение дава 0 точки:

 SELECT c.CityName, b.Name, COUNT(*) AS EmployeesCount FROM Cities AS c
       JOIN Branches AS b
         ON b.CityID = c.CityID
      AND b.CityID NOT IN (4,5)
     JOIN Employees AS e
        ON e.BranchID = b.BranchID
 GROUP BY c.CityName, b.Name
HAVING COUNT(*) >= 3 

 

А това решение минава:

 SELECT c.CityName, b.Name, COUNT(*) AS EmployeesCount FROM Cities AS c
  JOIN Branches AS b
    ON b.CityID = c.CityID
  JOIN Employees AS e
    ON e.BranchID = b.BranchID
 WHERE c.CityID NOT IN (4,5)
 GROUP BY c.CityName, b.Name
HAVING COUNT(*) >= 3 

0
Databases Basics
stambi4a avatar stambi4a 126 Точки

Резултатът в SSMS е същият, така че наистина е чудно. Aко групираш по CityId и BranchId, не по CityName и  BranchName, това пак има същият резултат в  SSMS, но не минава в judge.

0