日期:2014-05-18 浏览次数:20510 次
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
------解决方案--------------------
看這個行不行??
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