query-b75bff9d17b70a91ab158a3dbd12fe68

rq turtle/ttl

TODO

Use at

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?pays ?paysLabel (SUM(?number_or_0) AS ?numbers_2018) WHERE {
  ?item wdt:P31 wd:Q1248784 .
  OPTIONAL { ?item wdt:P17 ?pays0 . }
  BIND(IF(BOUND(?pays0),?pays0,wd:Q1) AS ?pays)
  OPTIONAL { ?item p:P3872 [pq:P585 ?time; ps:P3872 ?number ] }
  BIND(IF(BOUND(?number),?number,0) AS ?number_or_0)
  FILTER(("2018-01-01"^^xsd:date <= ?time) && ("2019-00-00"^^xsd:date > ?time))
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?pays ?paysLabel
ORDER BY DESC(?numbers_2018)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?item") v6("?number") v7("?number_or_0"):::projected v8("?numbers_2018") v5("?pays"):::projected v4("?pays0") v2("?time") a1((" ")) c4(["wd:Q1248784"]):::iri c10(["bd:serviceParam"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["'2018-01-01^^xsd:date' <= ?time'2019-00-00^^xsd:date' > ?time"]] f0 --> v2 v3 --"p:direct/P31"--> c4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P17".-> v4 end bind1[/"if(bound(?pays0),?pays0,'wd:Q1')"/] v4 --o bind1 bind1 --as--o v5 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; a1 -."p:qualifier/P585".-> v2 a1 --"p:statement/P3872"--> v6 v3 --"p:P3872"--> a1 end bind2[/"if(bound(?number),?number,'0^^xsd:integer')"/] v6 --o bind2 bind2 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end bind4[/"sum(?number_or_0)"/] v7 --o bind4 bind4 --as--o v8