qq_43198047 2019-05-14 11:27 采纳率: 0%
浏览 539
已采纳

消息130,级别15,状态 1,第 9 行 不能对包含聚合或子查询的表达式执行聚合函数。

select b.projectcd,b.projectnm,h.devicetypenm,sum(j.sums) as todaysums,sum((
select sum(j.sums)

       from  cloud_cm..cm_user a,cloud_ri..bi_project b,cloud_ri..bi_project_dt c,
       cloud_ri..bi_disaster d,cloud_ri..bi_dt_st_device e,cloud_ri..bi_stbprp_b f,
       cloud_ri..bi_device g,cloud_ri..bi_devicetype h,cloud_ri..ri_receivesum j
      where a.projectcd=b.projectcd and b.projectcd=c.projectcd  and c.dtcd=d.dtcd
      and e.dtcd=d.dtcd  and e.stcd=f.stcd  and e.devicecd=g.devicecd
      and h.devicetypecd=g.devicetypecd  and g.devicecd=j.devicecd  and a.usercd=2
       )) as    allsums

       from  cloud_cm..cm_user a,cloud_ri..bi_project b,cloud_ri..bi_project_dt c,
       cloud_ri..bi_disaster d,cloud_ri..bi_dt_st_device e,cloud_ri..bi_stbprp_b f,
       cloud_ri..bi_device g,cloud_ri..bi_devicetype h,cloud_ri..ri_receivesum j
      where a.projectcd=b.projectcd and b.projectcd=c.projectcd  and c.dtcd=d.dtcd
      and e.dtcd=d.dtcd  and e.stcd=f.stcd  and e.devicecd=g.devicecd
      and h.devicetypecd=g.devicetypecd  and g.devicecd=j.devicecd  
       and DATEDIFF(day,j.tm,GETDATE())=20            and a.usercd=2
      group by b.projectcd,b.projectnm,h.devicetypenm
  • 写回答

2条回答

  • threenewbee 2019-05-14 16:40
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器