ABSOLUT MASCULÍ

SELECT nom as sujeto, dni as doc, sexe as sex1, categoria as cate, IFNULL((SELECT puntsgen FROM historic5 WHERE idcursa=221 AND dni=doc ),0) AS dos, IFNULL((SELECT puntsgen FROM historic5 WHERE idcursa=222 AND dni=doc ),0) AS una, IFNULL((SELECT puntsgen FROM historic5 WHERE idcursa=223 AND dni=doc ),0) AS tres, IFNULL((SELECT puntsgen FROM historic5 WHERE idcursa=224 AND dni=doc ),0) AS quatre, IFNULL((SELECT puntsgen FROM historic5 WHERE idcursa=225 AND dni=doc ),0) AS cinc, IFNULL((SELECT puntsgen FROM historic5 WHERE idcursa=226 AND dni=doc ),0) AS sis, SUM(puntsgen) AS punts, SUM(empat) as desempat FROM historic5 WHERE sexe="M" GROUP BY dni ORDER BY punts DESC, desempat ASC..
Pos Nom Cat. AmpollaPerellóCamarlesTortosaDeltebreJesús Total Punts