计算并分组每个城镇在 table 中列出的次数

Count and group the number of times each town is listed in the table

SELECT PEOPLE.TOWNKEY, TOWN_LOOKUP.TOWN FROM PEOPLE
INNER JOIN TOWN_LOOKUP
ON PEOPLE.TOWNKEY = TOWN_LOOKUP.PK
 ORDER BY TOWN

当前Table输出:

您完全遗漏了 group by 子句:

SELECT     tl.town, COUNT(*)
FROM       people p
INNER JOIN town_lookup ON p.townkey = tl.pk
GROUP BY   tl.town
ORDER BY   tl.town