$sql = 'SELECT COUNT(*) FROM table WHERE f1 IS NOT NULL';
$results = $db->query($sql);
$numNonNullF1Values = $results->fetchColumn();
$sql = 'SELECT COUNT(*) FROM table WHERE f2 IS NOT NULL';
$results = $db->query($sql);
$numNonNullF2Values = $results->fetchColumn();
$sql = 'SELECT COUNT(*) FROM table WHERE f3 IS NOT NULL';
$results = $db->query($sql);
$numNonNullF3Values = $results->fetchColumn();
$totalNonNullValues = $numNonNullF1Values + $numNonNullF2Values + $numNonNullF3Values;