日期:2014-05-17 浏览次数:20795 次
select a.userid, a.username, sum(b.incost) sumincost, sum(c.outcost) sumoutcost from xxzx_user_zyl a,xxzx_incost b, xxzx_outcost c where a.userid=b.userid and b.userid=c.userid group by a.userid,a.username
------解决方案--------------------
SELECT userid,username,Sum(incost) over (PARTITION BY userid,username) as incost,Sum(outcost) over (PARTITION BY userid,username) as outcost FROM xxzx_user_zyl a,xxzx_incost b, xxzx_outcost c WHERE a.userid=b.userid(+) AND a.userid=c.userid(+)
------解决方案--------------------
select a.userid, a.username, sum(b.incost) sumincost, sum(c.outcost) sumoutcost from xxzx_user_zyl a,xxzx_incost b, xxzx_outcost c where a.userid=b.userid(+) and A.userid=c.userid(+) group by a.userid,a.username
是以A表为准,进行外关联