主表 链接community region
但是community和region并没有关联 所以主表一条数据跟这两个表命中两次导致查询count数不对, 求大神们提供一些别的写法
SELECT
count( 1 ) sum,
count(r.strCode),
bc.strDistrict,
bv.strCommunityGuid,
bc.strDistrictCode,
bv.strComeAdress
FROM
visitor bv
LEFT JOIN community bc ON bv.strCommunityGuid = bc.strCommunityCode
LEFT JOIN (select a.strCode from region a where a.strCode IN (
'420000',
'120115',
'120199'
) )r ON bv.strComeAdress = r.strCode
GROUP BY
bc.strDistrictCode
ORDER BY
bc.strDistrictCode