如果你有SELECT
一个GROUP BY
条款,在每列SELECT
列的列表必须要么聚集(SUM
,COUNT
,MAX
等),或者那么它必须是在GROUP BY
条款.
您的列表中有两个a.Name
并且未由聚合处理 - 因此,这两列必须出现在子句中a.About
SELECT
GROUP BY
SELECT a.Name, a.About, COUNT(b.Id) AS TotalCities, SUM(b.NoOfDwellers) AS TotalCityDwellers FROM Countries a LEFT JOIN Cities b ON a.Id = b.CountryId WHERE a.Name LIKE '%some str%' GROUP BY a.Id, a.About, a.Name ORDER BY a.Name ASC