SELECT ?s WHERE { ?s ?p ?o } GROUP BY ?s HAVING (?s) ("a") (!(COUNT(?o) > 1)) (-COUNT(?o)) (COUNT(?o) + 1)