query-89048152c1669cc385ffa8e9d3203019

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#>
#created by Mahir256, with help from CamelCaseNick
#defaultView:LineChart
select ?total (?totalCases - ?oldTotal as ?deltaCases) ?stateLabel {
  {
    wd:Q84055514 wdt:P527 ?statecases.
    ?statecases wdt:P276 ?state; p:P1603 ?a,?b.
    ?a ps:P1603 ?oldTotal; pq:P585 ?oldDate.
    ?b ps:P1603 ?totalCases; pq:P585 ?date.
    filter(?date - ?oldDate = 1.0)
    service wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  } union {
     { select (max(?cases_) as ?mc) {
       wd:Q84055514 wdt:P527/wdt:P1603 ?cases_
     } }
    [] wdt:P31 wd:Q21199 ; wdt:P1181 ?totalCases.
    filter(?totalCases <= xsd:integer(?mc))
    bind("(scale)" AS ?stateLabel)
    bind(?totalCases as ?oldTotal)
  }
  bind(str(?totalCases) as ?t)
  bind(concat(substr("0000", strlen(?t) + 1), ?t) as ?total)
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?a") v6("?b") v10("?cases_") v1("?date") v14("?deltaCases") v11("?mc") v2("?oldDate") v12("?oldTotal"):::projected v4("?state") v11("?stateLabel"):::projected v3("?statecases") v12("?t") v13("?total"):::projected v8("?totalCases"):::projected a2((" ")) a1((" ")) c14(["wd:Q21199"]):::iri c9(["bd:serviceParam"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal c2(["wd:Q84055514"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f0[["?totalCases <= http://www.w3.org/2001/XMLSchema#integer(?mc)"]] f0 --> v8 f0 --> v11 c2 --"p:direct/P527"--> a1 a1 --"p:direct/P1603"--> v10 bind2[/"max(?cases_)"/] v10 --o bind2 bind2 --as--o v11 a2 --"p:direct/P31"--> c14 a2 --"p:direct/P1181"--> v8 bind3[/"'(scale)'"/] bind3 --as--o v11 bind4[/"?totalCases"/] v8 --o bind4 bind4 --as--o v12 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f5[["?date - ?oldDate = '1.0^^xsd:decimal'"]] f5 --> v1 f5 --> v2 c2 --"p:direct/P527"--> v3 v3 --"p:direct/P276"--> v4 v3 --"p:P1603"--> v5 v3 --"p:P1603"--> v6 v5 --"p:statement/P1603"--> v12 v5 --"p:qualifier/P585"--> v2 v6 --"p:statement/P1603"--> v8 v6 --"p:qualifier/P585"--> v1 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end end union0r <== or ==> union0l end bind6[/"str(?totalCases)"/] v8 --o bind6 bind6 --as--o v12 bind7[/"concat(substring('0000',string-length(?t) + '1^^xsd:integer'),?t)"/] v12 --o bind7 bind7 --as--o v13 bind8[/"?totalCases - ?oldTotal"/] v8 --o bind8 v12 --o bind8 bind8 --as--o v14