sql计算两表相同列的和原创
原创问:如下表所示a,b,求num列的和
表a:
id
num
1
10
2
15
3
20
表b:
id
num
1
5
2
10
3
15
4
20
求num列中,结果如下:
id
sum(num)
1
15
2
25
3
35
4
20
解决方案:
select id,sum(num) as sum(num) from (select a.id,a.num from a union all select b.id,b.num from b) c GROUP BY id
结果:

版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
相关文章
最新文章
- An animated explainer of the PHP2SHell vulnerability [video] 40分钟前
- Sound of a guitar string cooling down on a piezo contact mic [video] 44分钟前
- How to fix your life in 1 day 46分钟前
- Ming dynasty statue unearthed in WA returns to China 2小时前
- Google has officially turned these Nest thermostats back into dumb thermostats 2小时前
- Show HN: Omni Verify, my AI agent can't post until Kane checks every promise 2小时前
- Club Cobra's Instagram page returns after 9-month battle with Meta 3小时前
- Finding Flaws in Technical Documentation 3小时前
- WikiCity – Explore 100k Wikipedia Articles as a 3D City 3小时前
- The Hackening 3小时前
itfan123

