query-0611fde8258dab483da8013a3a7b9179

rq turtle/ttl

List all items that have a main subject (P921) type description (earth sciences) (Q56241591) SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE { ?item wdt:P921 wd:Q83353; wdt:P50 ?namedAfterItem . OPTIONAL { ?namedAfterItem rdfs:label ?namedAfterItemLabel . FILTER(LANG(?namedAfterItemLabel) = 'en') . } SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' } } GROUP BY ?item ?itemLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
# List all items that have a main subject (P921) type description (earth sciences) (Q56241591)
SELECT ?item ?itemLabel (GROUP_CONCAT(?namedAfterItemLabel; separator=', ') AS ?namedAfter) WHERE {
  ?item wdt:P921 wd:Q83353; wdt:P50 ?namedAfterItem .
  OPTIONAL {
    ?namedAfterItem rdfs:label ?namedAfterItemLabel .
    FILTER(LANG(?namedAfterItemLabel) = 'en') .
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
} GROUP BY ?item ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v2("?item"):::projected v4("?namedAfter") v3("?namedAfterItem") v1("?namedAfterItemLabel"):::projected c3(["wd:Q83353"]):::iri c7(["bd:serviceParam"]):::iri c1(["en"]):::literal v2 --"wdt:P921"--> c3 v2 --"wdt:P50"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."rdfs:label".-> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c1 end bind1[/"?namedAfterItemLabel"/] v1 --o bind1 bind1 --as--o v4