如何使Count函数返回0?

1 sql function count

我试图在Access中创建一系列查询,计算77个县中每个县的每个种族的客户数量.

这是我的一个查询的SQL代码,我正在尝试这样做...

SELECT [ClientsByCounty-Asian].County, [ClientsByCounty-Asian].CountyName, Count([ClientsByCounty-Asian].Asian) AS CountOfAsian
FROM [ClientsByCounty-Asian]
GROUP BY [ClientsByCounty-Asian].County, [ClientsByCounty-Asian].CountyName;
Run Code Online (Sandbox Code Playgroud)

此查询仅返回77个县中的16个.我需要它显示所有77个县,即使结果为零并且没有记录.

如何让它显示其他61个县?

Qua*_*noi 8

假设您的77县存储在表中Counties:

SELECT  c.CountyName, COUNT([ClientsByCounty-Asian].County)
FROM    Counties c
LEFT JOIN
        [ClientsByCounty-Asian]
ON      [ClientsByCounty-Asian].County = c.County
GROUP BY
        c.County, c.CountyName
Run Code Online (Sandbox Code Playgroud)