查询语句中数据不完整,怎么添加呢
;with ts as (
select '人员报警信息' as Info,'0' as Counts
union all
select '井下对干人数' as Info,'0' as Counts
union all
select '重点区域人员' as Info,'0' as Counts
)
select ts.info,ISNULL(t.Counts,0) as Counts from (
select MineName,'人员报警信息' as info,count(Type)as Counts
from GL_RYDW_RealDeviceAlarm where Type='人员报警'
group by MineName,Type
union all
select MineName,'井下对干人数' as info,count(IsCadre)as Counts
from GL_RYDW_Information where IsCadre=1
group by MineName,IsCadre
union all
select MineName,'重点区域人员' as info,count(AreaType)as Counts
from GL_RYDW_Area where AreaType=1
group by MineName,AreaType
)as t
right join ts on ts.Info=t.info
where t.MineName = '名称'