query-695eedd6215901119aa07800067d6bc4

rq turtle/ttl

List all properties and their aliases used by a class or any of its subclassesI am looking to list all properties and their aliases used by a class or any of its subclasses. For example, I'd like to get all properties that make claims about a human (Q5), or all properties that make claims about a geographic area (city, state, country, region, etc.), or all properties that makes claims about an organization, etc. Ideally the properties would be sorted by how often they are used by the class and subclasses, but this isn't a requirement if all properties are returned. I've been using the two queries below, but they don't seem to capture all possible properties. Thanks for any help! Query A:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?class ?classLabel ?property ?propertyLabel (GROUP_CONCAT(?alias; separator="; ") AS ?aliases)
WHERE {
  ?tree0 (wdt:P279)* ?class .
  BIND (wd:Q5 AS ?tree0)
  ?class wdt:P1963 ?property .

  ?property a wikibase:Property ;
  rdf:type wikibase:Property ;
  wikibase:propertyType ?type ;
  skos:altLabel ?alias .

  FILTER(?type != wikibase:PropertyType && ?type != wikibase:ExternalId)
  FILTER(LANG(?alias) = "en")

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?class ?classLabel ?property ?propertyLabel
ORDER BY ?class ?propertyId

Query found at