query-cbd05418d8d9ab4b46809a62a1a3b6d0

rq turtle/ttl

TODO

Use at

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#>
#defaultView:Map{"layer":"?case_level"}
SELECT ?outbreak ?outbreakLabel ?map ?coord ?cases ?case_level ?deaths ?death_level ?CFR ?CFR_level ?start_time ?end_time
WHERE {
  ?outbreak p:P31 ?x.
  ?x ps:P31 ?y;
     pq:P642 wd:Q84263196.
  ?y wdt:P279* wd:Q3241045
  OPTIONAL {?outbreak wdt:P1846 ?map}
  OPTIONAL {?outbreak wdt:P625 ?coord}
  OPTIONAL {?outbreak wdt:P1603 ?cases}
  BIND(IF((?cases=0), "0", IF((?cases<10), "10^0 (1-9)", IF((?cases<100), "10^1 (10-99)", IF((?cases<1000), "10^2 (100-999)", IF((?cases<10000), "10^3 (1,000-9,999)", IF((?cases<100000), "10^4 (10,000-99,999)", IF((?cases<1000000), "10^5 (100,000-999,999)", ">=10^6 (1,000,000)" ))))))) AS ?case_level)
  OPTIONAL {?outbreak wdt:P1120 ?deaths}
  BIND(IF((?deaths=0), "0", IF((?deaths<10), "10^0 (1-9)", IF((?deaths<100), "10^1 (10-99)", IF((?deaths<1000), "10^2 (100-999)", IF((?deaths<10000), "10^3 (1,000-9,999)", ">=10^4 (10,000)" ))))) AS ?death_level)
  BIND (?deaths / ?cases AS ?CFR)
  BIND(IF((?CFR>=0.1), "10^-1 [10%,100%]", IF((?CFR>=0.01), "10^-2 [1%,10%)", IF((?CFR>=0.001), "10^-3 [0.1%,1%)", IF((?CFR>=0.0001), "10^-4 [0.01%,0.1%)", IF((?CFR=0), "0", ">0, <10^-4 (0%, 0.01%)" ))))) AS ?CFR_level)
  OPTIONAL {?outbreak wdt:P580 ?start_time}
  OPTIONAL {?outbreak wdt:P582 ?end_time}
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
ORDER BY ?case_level

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?CFR"):::projected v11("?CFR_level"):::projected v8("?case_level"):::projected v7("?cases"):::projected v6("?coord"):::projected v9("?death_level"):::projected v8("?deaths"):::projected v13("?end_time"):::projected v5("?map"):::projected v2("?outbreak"):::projected v12("?start_time"):::projected v3("?x") v4("?y") c4(["wd:Q84263196"]):::iri c6(["wd:Q3241045"]):::iri c14(["bd:serviceParam"]):::iri c16(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"p:P31"--> v3 v3 --"p:statement/P31"--> v4 v3 --"p:qualifier/P642"--> c4 v4 --"p:direct/P279"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P1846".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P625".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P1603".-> v7 end bind0[/"if(?cases = '0^^xsd:integer','0',if(?cases < '10^^xsd:integer','10^0 (1-9)',if(?cases < '100^^xsd:integer','10^1 (10-99)',if(?cases < '1000^^xsd:integer','10^2 (100-999)',if(?cases < '10000^^xsd:integer','10^3 (1,000-9,999)',if(?cases < '100000^^xsd:integer','10^4 (10,000-99,999)',if(?cases < '1000000^^xsd:integer','10^5 (100,000-999,999)','>=10^6 (1,000,000)')))))))"/] v7 --o bind0 bind0 --as--o v8 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P1120".-> v8 end bind1[/"if(?deaths = '0^^xsd:integer','0',if(?deaths < '10^^xsd:integer','10^0 (1-9)',if(?deaths < '100^^xsd:integer','10^1 (10-99)',if(?deaths < '1000^^xsd:integer','10^2 (100-999)',if(?deaths < '10000^^xsd:integer','10^3 (1,000-9,999)','>=10^4 (10,000)')))))"/] v8 --o bind1 bind1 --as--o v9 bind2[/"?deaths / ?cases"/] v8 --o bind2 v7 --o bind2 bind2 --as--o v10 bind3[/"if(?CFR >= '0.1^^xsd:decimal','10^-1 #91;10%,100%#93;',if(?CFR >= '0.01^^xsd:decimal','10^-2 #91;1%,10%)',if(?CFR >= '0.001^^xsd:decimal','10^-3 #91;0.1%,1%)',if(?CFR >= '0.0001^^xsd:decimal','10^-4 #91;0.01%,0.1%)',if(?CFR = '0^^xsd:integer','0','>0, <10^-4 (0%, 0.01%)')))))"/] v10 --o bind3 bind3 --as--o v11 subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P580".-> v12 end subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P582".-> v13 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c14 --"wikibase:language"--> c16 end