唯一地显示所有维基数据后代

Show all Wikidata descendants, uniquely

我有以下 working query,目的是显示 Q3314483 [1] 的所有子类:

SELECT ?item (SAMPLE(?itemLabel) AS ?itemLabel) (SAMPLE(?subclass) as ?subklass) (SAMPLE(?subclassLabel) AS ?subLabel) WHERE {
   ?item wdt:P279* wd:Q3314483 ;
         wdt:P279 ?subclass .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
group by ?item

SAMPLE and GROUP 模式旨在使项目独一无二。它似乎有效,但标签列是空白的。它们如何显示?

  1. Based on this

感谢评论中的@AKSW。答案是:

SELECT ?item (SAMPLE(?itemLabel) AS ?itemLabel) (SAMPLE(?subclass) as ?subklass) (SAMPLE(?subclassLabel) AS ?subLabel) WHERE {
  ?item wdt:P279* wd:Q3314483 ;
  wdt:P279 ?subclass . SERVICE wikibase:label {
    bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". ?subclass rdfs:label ?subclassLabel. ?item rdfs:label ?itemLabel.
  }
}
GROUP BY ?item