日期:2014-05-18  浏览次数:20510 次

散分有图,回答正确再加40分,急在线等

cpid=表A的ID图上打错了。
也就是这贴:
http://topic.csdn.net/u/20120207/14/d4b621e5-3e68-41b8-9ed4-d5e016d44994.html?seed=581880171&r=77492484#replyachor
一直没什么人回答,自己又搞不定,只好图给截下来,希望有老鸟帮帮帮,千万不要笑我菜,因为我真的很菜!
在线等,搞定马上结贴!

------解决方案--------------------
SQL code

select a.id,a.title,sum(b.tongji) as snt
from A a join B b on a.[user] = b.[user] and a.title = b.title
order by snt desc,a.id desc

--or

select a.id,a.title,sum(b.tongji) as snt
from A a,B b
where a.[user] = b.[user] and a.title = b.title
order by snt desc,a.id desc

------解决方案--------------------
select a.id,a.title,sum(b.tongji) as snt
from A a join B b on a.title = b.title
group by a.title,a.id
order by snt desc,a.id desc

------解决方案--------------------
看這個行不行??
SQL code

select a.id,a.mc,a.date,a.other,a.img,iif(isnull(sum(b.sl)),0,sum(b.sl)) as snt
from A as a left join B as b on a.id=b.cpid and a.mc=b.mc
group by a.id,a.mc,a.date,a.other,a.img
order by sum(b.sl) desc,a.id desc