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 dos, IFNULL((SELECT puntscat FROM historic WHERE idcursa=132 AND dni=doc ),0) AS tres, 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, IFNULL((SELECT puntscat FROM historic WHERE idcursa=140 AND dni=doc ),0) AS once, 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àrbaraCamarlesTortosaJesúsDeltebreLa GaleraL'Aldea Total Punts
1 BATALLA DOMINGUEZ, SITA 11510393930000000 404 404
2 GISBERT TORTA, VERÒNICA 10393115850000000 396 396
3 ALMEIDA JIMENEZ, MONICA 737970730000000 295 295
4 PARRAMON SOLER, GEMMA 85850790000000 249 249
5 SEGURA RIUS, ELENA 75071750000000 221 221
6 MARTÍNEZ ESQUERRÉ, MARIA TERESA 71750700000000 216 216
7 SANCHEZ HURTADO, CARMEN 9307300000000 166 166
8 LLAMBRICH PARRA, MONICA 0075710000000 146 146
9 CUÑAT SIMÓN , ENCARNA 0115000000000 115 115
10 MARTINEZ TORREGROSA, OLGA 0001150000000 115 115
11 TURTÓS PALOMA, NÚRIA 0001030000000 103 103
12 VERGE ANDRES, SONIA 0010300000000 103 103
13 NAVARRO AMADOR, IMMA 008500000000 85 85
14 GALVE CURTO, LUCI 007900000000 79 79
15 BERMEJO MULET, MONTSE 790000000000 79 79
16 MONSERRAT MONTAGUT, SÍLVIA 006900000000 69 69