sql 查询表中id字段相同所有条目的num字段的和
答案:1 悬赏:10 手机版
解决时间 2021-11-17 01:32
- 提问者网友:几叶到寒
- 2021-11-16 05:29
sql 查询表中id字段相同所有条目的num字段的和
最佳答案
- 五星知识达人网友:duile
- 2021-11-16 05:53
WITH a AS ( SELECt id1,
SUM(num1) AS _SUM
FROM 表1
GROUP BY id1
),
b AS ( SELECt id2 ,
SUM(num2) AS _SUM
FROM 表2
GROUP BY id2
)
SELECt *
FROM a ,
b
WHERe a.id1 = b.id2
AND a.[_SUM] = b.[_SUM]
试试这个
SUM(num1) AS _SUM
FROM 表1
GROUP BY id1
),
b AS ( SELECt id2 ,
SUM(num2) AS _SUM
FROM 表2
GROUP BY id2
)
SELECt *
FROM a ,
b
WHERe a.id1 = b.id2
AND a.[_SUM] = b.[_SUM]
试试这个
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯