34,838
社区成员




select B.Name,B.status,
sum(case when C.status <> 99 and A.Report = 1 then 1 else 0 end) pub_cnt,
sum(case when C.status = 1 and A.Report = 1 then 1 else 0 end) confirmed_cnt
from
Branch B
left outer join Content c
on B.Id = C.BranchId
left join Catalog A
on C.CatalogId = a.Id and B.Status<>99
and (datediff(s,C.commitdate,@EndTime)>0)
and (datediff(s,@StartTime,C.Commitdate)>0)
group by B.Name,B.status order by B.Name
--try
select B.Name,B.status,
sum(case when C.status <> 99 and A.Report = 1 then 1 else 0 end) pub_cnt,
sum(case when C.status = 1 and A.Report = 1 then 1 else 0 end) confirmed_cnt
from
Branch B
left outer join Content c
on B.Id = C.BranchId
left join Catalog A
on C.CatalogId = a.Id
where B.Status<>99
and (datediff(s,C.commitdate,@EndTime)>0)
and (datediff(s,@StartTime,C.Commitdate)>0)
group by B.Name,B.status order by B.Name
and B.Status<>99===>>Where B.Status<>99