两条求和sql语句相加

Y青阳 2018-08-16 04:28:07

如何将这两条sql语句进行求和,求大神指点
或者如何将这两条语句合并成一条
...全文
1054 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Y青阳 2018-08-17
  • 打赏
  • 举报
回复 1
引用 1 楼 yenange 的回复:
select sum(n) from (
select sum(a.lhfgmjms) as n from jc_jbdcjzb a where ( a.trzldm='16' )
union all
select sum(b.lhfgmjms) as n from jc_fslddcjzb b where ( b.trzldm='16' )
) as t



谢谢啊 ,已采用了!
吉普赛的歌 2018-08-16
  • 打赏
  • 举报
回复
引用 2 楼 weixin_42177002 的回复:
[quote=引用 1 楼 yenange 的回复:]
select sum(n) from (
select sum(a.lhfgmjms) as n from jc_jbdcjzb a where ( a.trzldm='16' )
union all
select sum(b.lhfgmjms) as n from jc_fslddcjzb b where ( b.trzldm='16' )
) as t
去重用union ,不去重用union all[/quote]
人家要求的是最后的总和,去重了还怎么求和?
男哥不喝酒 2018-08-16
  • 打赏
  • 举报
回复
引用 1 楼 yenange 的回复:
select sum(n) from (
select sum(a.lhfgmjms) as n from jc_jbdcjzb a where ( a.trzldm='16' )
union all
select sum(b.lhfgmjms) as n from jc_fslddcjzb b where ( b.trzldm='16' )
) as t
去重用union ,不去重用union all
吉普赛的歌 2018-08-16
  • 打赏
  • 举报
回复
select sum(n) from (
select sum(a.lhfgmjms) as n from jc_jbdcjzb a where ( a.trzldm='16' )
union all
select sum(b.lhfgmjms) as n from jc_fslddcjzb b where ( b.trzldm='16' )
) as t

22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧