select * from gdata
campain num name file score player
------------- ------ --------- --------- -------- ---------
Campain One 1 Level One test1.xml 1221 john
Campain One 1 Level Two test1.xml 122 john
Campain One 1 Level Two test1.xml 122 dereck
Campain One 1 Level Two test1.xml 122 jon
Campain Two 1 Level Two test1.xml 122 jon
Campain Two 1 Level Two test1.xml 122 jon
Campain Two 1 Level Two test2.xml 122 jon
Campain Three 1 Level Two test2.xml 1122 jon
Campain Three 1 Level Two test2.xml 1122 jon
Campain Three 1 Level Two test2.xml 1122 derekk
select 'All' as campain ,'All'as player,sum(score) score from gdata
union
select campain,player,sum(score) as score from gdata group by campain,player
campain player score
------------- --------- --------
All All 5319
Campain One dereck 122
Campain One john 1343
Campain One jon 122
Campain Three derekk 1122
Campain Three jon 2244
Campain Two jon 366
select campain,sum(score) as score from gdata group by campain
campain score
------------- --------
Campain One 1587
Campain Three 3366
Campain Two 366
select campain,player,max(score) from (
select campain,player,sum(score) as score from gdata
group by campain,player order by score desc
) as b
group by campain
campain player score
------------- --------- -------------
Campain One john 1343
Campain Three jon 2244
Campain Two jon 366
我認爲需要一些澄清。 1)發表一些關於你的競選列表想法的草圖/解釋,以及2)你的桌子是如何建立的(哪些列)。 – Yar 2012-02-11 16:05:23
'選擇campain,來自gdata group by campain'的總和(分數)......如果我說得對。如果你想添加播放器添加播放器來選擇和分組' – 2012-02-11 16:29:42
不'選擇廣告系列...也會返回來自廣告系列的重複?而且,這不是給我所有級別的總分嗎? – user717572 2012-02-11 16:40:43