sqlserver 查询语句中没有显示数据,怎么补上呢?

查询语句中数据不完整,怎么添加呢

;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 = '名称'

图片说明

没有数据,我也不敢乱说。我觉得,如果把记的数转为String类型的,会不会显示呢?

CONCAT(count(AreaType)) 

上面'0' as Counts,
下面count(AreaType);

这类型不知道是不是一致?

把right join 改成 left join

看错了,right join 是对的,不好意思,解决了就好,不过,我这边测试了下结果你的代码应该没问题的

图片说明