您可以使用简单的分组方式在没有子查询的情况下进行尝试:
SELECt voterfile_county.Name, voterfile_precienct.PREC_ID, voterfile_precienct.Name, count(voterfile_voter.ID)FROM voterfile_countyJOIN voterfile_precienct ON voterfile_precienct.County_ID = voterfile_County.IDJOIN voterfile_household ON voterfile_household.Precnum = voterfile_precienct.PREC_IDJOIN voterfile_voter ON voterfile_voter.House_ID = voterfile_household.ID GROUP BY voterfile_county.Name, voterfile_precienct.PREC_ID, voterfile_precienct.Name
使用GROUP BY时,未分组的任何列都必须具有聚合子句(fe
SUM或COUNT。)因此,在这种情况下,您必须对县名称,precienct.id和precient.name进行分组。



