ABSOLUT MASCULÍ

SELECT nom as sujeto, dni as doc, sexe as sex1, categoria as cate, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=130 AND dni=doc ),0) AS una, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=131 AND dni=doc ),0) AS tres, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=132 AND dni=doc ),0) AS dos, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=133 AND dni=doc ),0) AS quatre, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=134 AND dni=doc ),0) AS cinc, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=135 AND dni=doc ),0) AS sis, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=136 AND dni=doc ),0) AS siet, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=137 AND dni=doc ),0) AS vuit, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=138 AND dni=doc ),0) AS nou, IFNULL((SELECT puntsgen FROM historic WHERE idcursa=139 AND dni=doc ),0) AS deu, SUM(puntsgen) AS punts, SUM(empat) as desempat FROM historic WHERE sexe="M" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom Cat. AmpostaL'AmpollaUlldeconaPerellóS.BàrbaraCamarlesTortosaDeltebreLa GaleraJesús Total Punts