l'ordine delle parentesi è sbagliato:

"SELECT IF (ISNULL(COUNT(sesso)),0,COUNT(sesso)) AS numero FROM tab..."