首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

散分有图,回答正确再加40分,

2012-03-13 
散分有图,回答正确再加40分,急在线等cpid表A的ID图上打错了。也就是这贴:http://topic.csdn.net/u/2012020

散分有图,回答正确再加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 sntfrom A a join B b on a.[user] = b.[user] and a.title = b.titleorder by snt desc,a.id desc--orselect a.id,a.title,sum(b.tongji) as sntfrom A a,B bwhere a.[user] = b.[user] and a.title = b.titleorder 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 sntfrom A as a left join B as b on a.id=b.cpid and a.mc=b.mcgroup by a.id,a.mc,a.date,a.other,a.imgorder by sum(b.sl) desc,a.id desc 

热点排行