VETERÀ-2 FEMENÍ

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="VE2 F" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom AmpollaPerellóCamarlesTortosaDeltebreJesús Total Punts
1 DEL CAMPO SANZ, PATRICIA 115001151150 345 345
2 HERNANDEZ HERRERO, MARTA 1030103000 206 206
3 ALABART ALCOBER, XUS 009301030 196 196
4 ALMEIDA JIMENEZ, MONICA 00859300 178 178
5 BAGES BANEGAS, SANDRA 00115000 115 115
6 SEGURA RIUS, ELENA 00010300 103 103
7 MUÑOZ LÓPEZ, ISABEL 9300000 93 93
8 LOPEZ LOPEZ, SABRINA 8500000 85 85
9 HENDERSON, WENDY 7900000 79 79