Buried,
sum(case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000003' then 1 else 0 end) LockDoor,
sum(case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000004' then 1 else 0 end) MeterWaterFuzzy,
sum(case when w.hx_freading is null then 1 else 0 end) hx_freading
from hx_t_waterusedamount w--水量
INNER JOIN hx_t_receivable r --应收
ON w.hx_t_waterusedamountid=r.hx_fusedamountid and w.hx_FYear=@FYear and w.hx_FMonth=@FMonth
--团队
INNER JOIN Team t
ON w.OwningTeam = t.TeamId
--部门
INNER JOIN BusinessUnit u
ON t.BusinessUnitId = u.BusinessUnitId
GROUP BY u.ParentBusinessUnitIdName,
t.Name WITH ROLLUP
---------------------------------------------------------------------------
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'