PREFIX : SELECT (:foo AS ?foo) (COUNT(?outObject) AS ?out) WHERE { ?s :predicate ?outObject } GROUP BY ?s