SÈNIOR MASCULÍ

SELECT nom as sujeto, dni as doc, sexe as sex1, categoria as cate, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=221 AND dni=doc ),0) AS una, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=222 AND dni=doc ),0) AS dos, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=223 AND dni=doc ),0) AS tres, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=224 AND dni=doc ),0) AS quatre, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=225 AND dni=doc ),0) AS cinc, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=226 AND dni=doc ),0) AS sis, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=227 AND dni=doc ),0) AS siet, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=228 AND dni=doc ),0) AS vuit, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=229 AND dni=doc ),0) AS nou, SUM(puntscat) AS punts, SUM(empat) as desempat FROM historic5 WHERE categoria="SEN M" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom AmpostaAmpollaPerellóCamarlesTortosaJesúsDeltebreL'Aldea Total Punts
1 ROCA REY, ROGER 73737500000 221 221
2 TOMÀS BUITRAGO, AITOR 115010300000 218 218
3 MACHI CABALLE, OMAR 93115000000 208 208
4 ESTORACH SOL, OSCAR 103103000000 206 206
5 GOMEZ AUSACH, ANDREU 7985000000 164 164
6 BERTOMEU CASANOVA, AARON 7575000000 150 150
7 CUBELLS I CUBELLS, HERIBERT 0011500000 115 115
8 CASAS CABRERA, PACO 093000000 93 93
9 JIMÉNEZ BRANERA , DANI 009300000 93 93
10 CÁCERES AZNAR, KARIM 850000000 85 85
11 MAIJÓ FRIGOLA, ABEL 008500000 85 85
12 CURTO GARCIN, CARLOS 079000000 79 79
13 GABALDA FERRE, ELOI 007900000 79 79
14 DUSSARRAT, ROBIN 071000000 71 71
15 PAGA FABRA, AGUSTI 070000000 70 70