select a.Aid,min(Aname) as Aname,sum(Bmoney) as Bmoney ,sum(Cmoney) as Cmoney from C inner jon (B inner join A on A.Aid=B.Aid) on B.Bid=C.Bid group by a.Aid
select *,(select sum(bmoney) from b表 where aid=tem.aid) Bmoney,(select sum(cmoney) from c表 where bid in (select bid from b表 where aid=tem.aid)) cmoney from A表 tem
select A.Aid,BMoney,CMoney from A inner join (select Aid,sum(BMoney) BMoney from B group by Aid) t on a.Aid=t.Aid inner join (select Aid,sum(CMoney) CMoney from A inner join B on a.aid=b.aid inner join C on b.bid=c.bid group by Aid ) s on a.Aid=s.Aid
to pengdali(大力) ﹕tem代表什么 to w_rose(w_rose):s﹑t分別代表什么 能不能說清楚點
謝謝pengdali(大力) to w_rose(w_rose): "select A.Aid,BMoney from A inner join (select Aid,sum(BMoney) BMoney from B group by Aid) t on a.Aid=t.Aid "能通得過﹐但 "select A.Aid,BMoney,CMoney from A inner join (select Aid,sum(BMoney) BMoney from B group by Aid) t on a.Aid=t.Aid inner join (select Aid,sum(CMoney) CMoney from A inner join B on a.aid=b.aid inner join C on b.bid=c.bid group by Aid ) s on a.Aid=s.Aid" 不能通過﹐什么原因
select aid ,sum(bmoney),sum(cmoney)from (select aid,sum(bmoney) as bmoney,0 as cmoney from a,b where a.aid=b.aid group by aid union all select aid,0 , sum(cmoney) from b ,c where b.bid=a.bid group by aid) as a group by aid
from A
inner join (select Aid,sum(BMoney) BMoney from B group by Aid) t on a.Aid=t.Aid
inner join
(select Aid,sum(CMoney) CMoney
from A
inner join B on a.aid=b.aid
inner join C on b.bid=c.bid group by Aid
) s on a.Aid=s.Aid
to w_rose(w_rose):s﹑t分別代表什么
能不能說清楚點
to w_rose(w_rose):
"select A.Aid,BMoney
from A
inner join (select Aid,sum(BMoney) BMoney from B group by Aid) t on a.Aid=t.Aid
"能通得過﹐但
"select A.Aid,BMoney,CMoney
from A
inner join (select Aid,sum(BMoney) BMoney from B group by Aid) t on a.Aid=t.Aid
inner join
(select Aid,sum(CMoney) CMoney
from A
inner join B on a.aid=b.aid
inner join C on b.bid=c.bid group by Aid
) s on a.Aid=s.Aid"
不能通過﹐什么原因
union all
select aid,0 , sum(cmoney) from b ,c where b.bid=a.bid group by aid) as a
group by aid