query-fe6498cbc312d8e7ada21519ab08b024

rq turtle/ttl

wrong SELECT ?obituaries ?autho ?authoLabel ?year WHERE { { SELECT (MAX(?total_obituaries) as ?obituaries) (MAX(?author) as ?autho) ?year WHERE { { SELECT ?author (count(?q) as ?total_obituaries) ?year WHERE { ?q wdt:P1433 wd:Q9684 ; wdt:P31 wd:Q309481 . ?q wdt:P50 ?author . ?q wdt:P577 ?date . BIND(YEAR(?date) AS ?year) . FILTER(?year IN (2022, 2021)). } GROUP BY ?author ?year } } GROUP BY ?year
} SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr". } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# wrong
SELECT ?obituaries ?autho ?authoLabel ?year WHERE {
  {
    SELECT (MAX(?total_obituaries) as ?obituaries) (MAX(?author) as ?autho) ?year WHERE {
      {
        SELECT ?author (count(?q) as ?total_obituaries) ?year WHERE {
          ?q wdt:P1433 wd:Q9684 ; wdt:P31 wd:Q309481 .
          ?q wdt:P50 ?author .
          ?q wdt:P577 ?date .
          BIND(YEAR(?date) AS ?year) .
          FILTER(?year IN (2022, 2021)).
        }
        GROUP BY ?author ?year
      }
    }
    GROUP BY ?year  
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,fr". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?autho"):::projected v3("?author") v4("?date") v6("?obituaries"):::projected v2("?q") v5("?total_obituaries") v5("?year"):::projected c4(["wd:Q9684"]):::iri c10(["bd:serviceParam"]):::iri c6(["wd:Q309481"]):::iri c12(["en,fr"]):::literal list0c1(["2022^^xsd:integer"]):::literal list0c2(["2021^^xsd:integer"]):::literal list0c1 --o f0 list0c2 --o f0 f0[[" in "]] f0 --> v5 v2 --"wdt:P1433"--> c4 v2 --"wdt:P31"--> c6 v2 --"wdt:P50"--> v3 v2 --"wdt:P577"--> v4 bind1[/"year-from-dateTime(?date)"/] v4 --o bind1 bind1 --as--o v5 bind3[/"count(?q)"/] v2 --o bind3 bind3 --as--o v5 bind6[/"max(?total_obituaries)"/] v5 --o bind6 bind6 --as--o v6 bind7[/"max(?author)"/] v3 --o bind7 bind7 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end