1 USA 10.2900
2 Japan 10.4230
3 Thailand 10.4600
4 China 10.5210
5 Germany 10.8600
6 Poland 11.0020
7 Italy 11.1000
8 Taiwan 11.1020
9 Indonesia 11.1860
10 Canada 11.4840
11 Malaysia 11.8220
12 France 11.8220
13 United Kingdom 11.9440
14 Hungary 12.1120
15 Korea 12.1290
16 Philippines 12.1720
17 Sweden 12.2380
18 Spain 12.2550
19 Netherlands 12.3210
20 Russia 12.4670
21 Brazil 12.4950
22 Vietnam 12.5800
23 Australia 12.7800
24 Hong Kong 12.9400
25 Singapore 13.9800
26 Finland 14.4540
27 Chile 14.5090
28 Norway 14.5440
29 Austria 14.6180
30 Denmark 15.2320
31 Israel 16.0330
32 India 16.0360
33 Mexico 16.3790
34 New Zealand 16.5420
35 Belgium 17.3660
36 Ukraine 17.4970
37 Colombia 18.6490
38 Romania 19.0260
39 Peru 19.8930
40 Switzerland 20.8720
41 Argentina 22.5860
42 Slovenia 23.0110
43 Portugal 24.9430
44 Estonia 27.4000
45 Czech Republic 27.5890
46 Greece 39.9910
47 Slovakia 42.2470
Query (not exactly recommended):
select
@num2 := @num2 + 1 as row_number,
o.country,
o.score
from
(
select
n.country,
(sum(n.average) / 1000) as score,
max(n.row_number) as row_counter
from
(
select
m.country,
m.person,
m.average,
@num := if(@group = m.country, @num + 1, 1) as row_number,
@group := m.country as dummy,
@num2:= 0
from
(
select
results.personCountryId as country,
results.personName as person,
min(results.average) as average
from results
where results.eventId like '333' and results.average > 0
group by results.personId, results.personCountryId
order by results.personCountryId, average
)
m
)
n
where
n.row_number <=10
group by n.country
order by score
)
o
where o.row_counter >=10