PREFIX  rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX  :       <http://example/>
PREFIX  dc:     <http://purl.org/dc/elements/1.1/>

SELECT ?p (count(*) AS ?c) (count(distinct *) AS ?cd) 
{
    # UNION is asymmetric in what it generates
    { ?x rdf:type :X . } UNION { ?x rdf:type :X . FILTER (?x != :x2 )}
    # and :x2 :p 2 with ":p 2" occuring twice.
    ?x :p ?p .
}
GROUP BY ?p
