Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH Grouped (TownName, EmployeesCount)
- AS
- (
- SELECT t.Name, COUNT(e.EmployeeID) AS EmployeesCount FROM Employees e
- JOIN Addresses a ON e.AddressID = a.AddressID
- JOIN Towns t ON a.TownID = t.TownID
- GROUP BY t.Name
- )
- SELECT TownName, EmployeesCount
- FROM Grouped g
- WHERE g.EmployeesCount =
- (SELECT MAX(s.EmployeesCount) AS MaxCount
- FROM Grouped s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement