VETERÀ-1 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 dos, IFNULL((SELECT puntscat FROM historic5 WHERE idcursa=222 AND dni=doc ),0) AS una, 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, SUM(puntscat) AS punts, SUM(empat) as desempat FROM historic5 WHERE categoria="VE1 M" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom AmpollaPerellóCamarlesTortosaDeltebreJesús Total Punts
1 BALAGUE BELTRAN, JOAQUIN 93937911500 380 380
2 GRUESO OTALO, ANTONIO 1151150000 230 230
3 TORREBLANCA CERVELLÓ, JOSE ANGEL 007310300 176 176
4 ORTEGA BLANCO, JAIME 08575000 160 160
5 EL JIHAOUI, AZZIZ 00115000 115 115
6 RIERA FLORES, JORDI 10300000 103 103
7 TORTOSA, DAVID 00103000 103 103
8 ALBACAR CLIMENT, CONRAD 01030000 103 103
9 GARCÍA ANTA , JESUS 0093000 93 93
10 TORRES , JORGE 0085000 85 85
11 POQUET DOMENECH, PAU 8500000 85 85
12 FUSTER GIL, ANGEL LLUIS 0790000 79 79
13 BRULL MARGALEF, JORDI 0750000 75 75
14 SAMANIEGO GOMEZ, XAVI 0730000 73 73
15 MARTI MARTI, MARC SEBASTIA 0071000 71 71
16 ALBIAC VIÑOLAS, FERRAN 0710000 71 71
17 TERAN GOMEZ, JOAN 0070000 70 70
18 GONZÀLEZ CORTINA, OSCAR 0700000 70 70
19 OLLE CAMPAMA, FRANCESC 0069000 69 69