VETERÀ-2 MASCULÍ

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 M" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom AmpostaL'AmpollaUlldeconaPerellóS.BàrbaraCamarlesTortosaJesúsDeltebreLa GaleraL'Aldea Total Punts
1 FORNÉ CASTELLS, XAVIER 1150000000000 115 115
2 PEREZ MUÑOZ, FRANCISCO JESUS 1030000000000 103 103
3 MONTERO PÈREZ, JOSEP MARIA 930000000000 93 93
4 ALABART ALCOBER, JOSEP MARIA 850000000000 85 85
5 GRAU SANZ, MAX 790000000000 79 79
6 TONDA SALVADÓ, JOSEP LLUIS 750000000000 75 75
7 CURTO I GILABERT, DAVID 730000000000 73 73
8 GARCIA SANGÜESA, DAMIÀ 710000000000 71 71
9 ALIMBAU REVERTE, MIQUEL 700000000000 70 70
10 ESQUERRE FERRE, ROMAN 690000000000 69 69
11 ACERO VENDRELL, ALVARO 680000000000 68 68
12 LLUIS LLANSAMA, GABRIEL 670000000000 67 67
13 LLEIXÀ CHAVARRIA, JOSEP 660000000000 66 66
14 SERRET ROIG, ADRIA 650000000000 65 65
15 CABANES CALVET, ALBERT 640000000000 64 64
16 LLETI NAVARRO, FERNANDO 630000000000 63 63
17 FIBLA REVERTER, HERMINI 620000000000 62 62
18 LEÓN MORA, AUGUSTO LEO 610000000000 61 61
19 VALDIVIAS AHUMADA, OSCAR 600000000000 60 60
20 FORTUÑO NAVARRO, JOSE LUIS 590000000000 59 59
21 GARCIA DRAGO, JOSEP 580000000000 58 58
22 MASOLLER ARIAS, FRANCESC 570000000000 57 57
23 CAÑÍS SÁNCHEZ, DANIEL 560000000000 56 56
24 REVERTER BULLON, JOSE MIGUEL 550000000000 55 55
25 GRANGÉ GALINDO, JOSEP LLUIS 540000000000 54 54
26 TOMÀS I ROIGET, ADAM 530000000000 53 53
27 ADELL WINKLER, PERE 520000000000 52 52
28 BELTRAN SUBIRATS, JOSEP MARIA 510000000000 51 51
29 LOZANO HERNANDEZ, JOSE MARIA 500000000000 50 50