query-cd9e33794053963aef91910012da10bf

rq turtle/ttl

Getting the unit of a quantityHi, I have the following query:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?property ?propertyLabel ?value ?valueLabel ?unit ?unitLabel

WHERE {
   {
  SELECT ?item ?property ?value ?unit
  WHERE {
     {
  SELECT ?statement WHERE { 
      ?statement prov:wasDerivedFrom/pr:P248 wd:Q105645500 .
  }
  LIMIT 2000
}    ?item ?p ?statement .
    ?property wikibase:claim ?p . 
    ?statement ?a ?value .
    ?item ?b ?value .         
    OPTIONAL { ?value wikibase:quantityUnit/wikibase:unit ?unit}
  }
}  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } 
} 
ORDER BY DESC(?itemLabel)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?a") v8("?b") v3("?item"):::projected v1("?itemLabel"):::projected v4("?p") v5("?property"):::projected v2("?statement") v9("?unit"):::projected v7("?value"):::projected a1((" ")) a2((" ")) c8(["bd:serviceParam"]):::iri c10(["en"]):::literal c3(["wd:Q105645500"]):::iri v2 --"prov:wasDerivedFrom"--> a1 a1 --"pr:P248"--> c3 v3 -->v4--> v2 v5 --"wikibase:claim"--> v4 v2 -->v6--> v7 v3 -->v8--> v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v7 -."wikibase:quantityUnit".-> a2 a2 --"wikibase:unit"--> v9 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end