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

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);

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

    评论

报告相同问题?

悬赏问题

  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥85 maple软件,solve求反函数,出现rootof怎么办?
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题