ho provato a fare

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

ma mi da errore