VETERÀ-1 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="VE1 F" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom AmpollaPerellóCamarlesTortosaDeltebreJesús Total Punts
1 SÁNCHEZ FIGUERES , MIREIA 1159393000 301 301
2 MONTEVERDE MICHAVILA, MONICA 1037975000 257 257
3 FANDOS COLOMINES, ESTIBALIZ 738573000 231 231
4 CÓRDOVA ANDINO , YESENIA 0115103000 218 218
5 ZARAGOZA GRANELL, SUSANA 0103115000 218 218
6 MARTOS REDO , IOLANDA 79070000 149 149
7 MORALES TOMÀS , PATRICIA 75071000 146 146
8 COMÍ CODINA , SÒNIA 70750000 145 145
9 MONTAÑA VALLÉS, CARME 9300000 93 93
10 FORT RODRIGUEZ, ROSANA 0085000 85 85
11 VILANOVA BAIGES, SÍLVIA 8500000 85 85
12 BIARNÉS JORNET, MªDOLORS 0079000 79 79
13 POQUET TARRAGO, NOEMI 7100000 71 71
14 CUGAT ADELL, GEMMA 0069000 69 69
15 LARA, CLARISA 6900000 69 69
16 RODRÍGUEZ AUBÀ, EUGÈNIA 0068000 68 68
17 VILANOVA BAIGES, MERITXELL 6800000 68 68