select a.plate_number 车牌,isnull(b.超速,0)超速,isnull(c.超载,0)超载
from car_report a left join
(select plate_number,COUNT(*) as 超速 from exceed_report group by plate_number) b
on a.plate_number=b.plate_number left join
(select plate_number,COUNT(*) as 超载 from associat_report group by plate_number) c
on a.plate_number=c.plate_number
select a.*,b.超载 from
(select plate_number,COUNT(*) as 超速 from exceed_report group by plate_number) a left join
(select plate_number,isnull(COUNT(*),0) as 超载 from associat_report group by plate_number) b on a.plate_number=b.plate_number