VETERÀ-2 FEMENÍ

SELECT nom as sujeto, dni as doc, sexe as sex1, categoria as cate, IFNULL((SELECT puntscat FROM historic WHERE idcursa=130 AND dni=doc ),0) AS una, IFNULL((SELECT puntscat FROM historic WHERE idcursa=131 AND dni=doc ),0) AS tres, IFNULL((SELECT puntscat FROM historic WHERE idcursa=132 AND dni=doc ),0) AS dos, IFNULL((SELECT puntscat FROM historic WHERE idcursa=133 AND dni=doc ),0) AS quatre, IFNULL((SELECT puntscat FROM historic WHERE idcursa=134 AND dni=doc ),0) AS cinc, IFNULL((SELECT puntscat FROM historic WHERE idcursa=135 AND dni=doc ),0) AS sis, IFNULL((SELECT puntscat FROM historic WHERE idcursa=136 AND dni=doc ),0) AS siet, IFNULL((SELECT puntscat FROM historic WHERE idcursa=137 AND dni=doc ),0) AS vuit, IFNULL((SELECT puntscat FROM historic WHERE idcursa=138 AND dni=doc ),0) AS nou, IFNULL((SELECT puntscat FROM historic WHERE idcursa=139 AND dni=doc ),0) AS deu, SUM(puntscat) AS punts, SUM(empat) as desempat FROM historic WHERE categoria="VE2 F" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom AmpostaL'AmpollaUlldeconaPerellóS.BàrbaraCamarlesTortosaDeltebreLa GaleraJesús Total Punts
1 TURTÓS PALOMA, NÚRIA 10310309379103115000 596 596
2 DOMINI VIDAL, SILVIA 1150115103850103000 521 521
3 BATALLA DOMINGUEZ, SITA 011501151031150000 448 448
4 GONZALEZ SABATE, TRINI 710797571750000 371 371
5 SEGURA RIUS, ELENA 73750790790000 306 306
6 AGUEYO BENITO, MILA 0797573000000 227 227
7 LLAMBRICH PARRA, MONICA 0010385000000 188 188
8 ROJAS PEREZ, CARMEN 085930000000 178 178
9 ROIG CASTELL, EVA 000011500000 115 115
10 ARASA SUBIRATS, MARISIN 00009300000 93 93
11 QUERAL MOLINÉ, EVELIN 00000930000 93 93
12 SANCHEZ HURTADO, CARMEN 93000000000 93 93
13 DRECKER, SABINE 09300000000 93 93
14 CLUA I GAYA, MARISA 00000850000 85 85
15 BERMEJO MULET, MONTSE 85000000000 85 85
16 CALVET ESCUIN, JÚLIA 00850000000 85 85
17 PERPIÑA CUEVAS, MAR 79000000000 79 79
18 CERDÀ GARCIA, MONTSE 00007500000 75 75
19 GARCIA ESTELLE, MARIA JOSÉ 75000000000 75 75
20 MORA GRATACOS, IRENE 00000730000 73 73
21 ALMEIDA JIMENEZ, MONICA 00007300000 73 73