柠檬也有梦 2020-06-19 20:32 采纳率: 50%
浏览 525

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

图片说明

  • 写回答

2条回答

  • 零壹c 2020-06-20 00:47
    关注

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

    CONCAT(count(AreaType)) 
    

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

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

    评论

报告相同问题?