mysql 多表联合统计
答案:3 悬赏:70 手机版
解决时间 2021-11-09 12:09
- 提问者网友:原来太熟悉了会陌生
- 2021-11-09 00:28
mysql 多表联合统计
最佳答案
- 五星知识达人网友:鱼芗
- 2021-11-09 01:20
SELECt m.user_id, b_total, c_total, d_total FROM a m, (SELECt user_id, COUNT(*) b_total FROM b GROUP BY user_id) n,
(SELECt user_id, COUNT(*) c_total FROM c GROUP BY user_id) j, (SELECt user_id, COUNT(*) d_total FROM d GROUP BY user_id) k,
WHERe m.user_id = n.user_id AND m.user_id = j.user_id AND m.user_id = k.user_id;
(SELECt user_id, COUNT(*) c_total FROM c GROUP BY user_id) j, (SELECt user_id, COUNT(*) d_total FROM d GROUP BY user_id) k,
WHERe m.user_id = n.user_id AND m.user_id = j.user_id AND m.user_id = k.user_id;
全部回答
- 1楼网友:妄饮晩冬酒
- 2021-11-09 02:28
select a.id,sum(b.datab),sum(c.datac),sum(d.datad) from a,b,c,d
where a.id=b.id(+)
and a.id=c.id(+)
and a.id=d.id(+)
group by a.id
where a.id=b.id(+)
and a.id=c.id(+)
and a.id=d.id(+)
group by a.id
- 2楼网友:猎心人
- 2021-11-09 02:03
select (b.b_total + c.c_total + d.d_total) as `sum` from a,b,c,d where a.user_id = b.user_id and b.user_id = c.user_id and c.user_id = d.user_id and d.user_id = a.user_id and a.user_id < 100
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯