现在要做的是统计在某个时间段[beginTime,endTime](其中beginTime,endTime由前台进行传入)内,每个上报人上报错误点的总数以及已解决错误的总数。
select a.ReportPerson,a.sumOfError,b.solvedError
from(select COUNT(ErrorID) as sumOfError,ReportPerson
from PCR_ConstructInfo
where
(ReportTime>beginTime) and (ReportTime<endTime) group by ReportPerson)
a left join
(select ReportPerson,COUNT(ErrorID) as solvedError
from PCR_ConstructInfo
where (State=2) and (ReportTime>beginTime) and (ReportTime<endTime) group by ReportPerson) b
on (a.ReportPerson=b.ReportPerson)
生成的结果图为: